Created
September 21, 2018 05:05
-
-
Save sdcb/25fdbb8d46d91d9091b3496cc228a8e9 to your computer and use it in GitHub Desktop.
sdmap test(LINQPad).linq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Query Kind="Statements"> | |
<Reference><RuntimeDirectory>\System.Configuration.dll</Reference> | |
<Reference><RuntimeDirectory>\System.Data.Services.Client.dll</Reference> | |
<Reference><RuntimeDirectory>\System.Data.Services.Design.dll</Reference> | |
<Reference><RuntimeDirectory>\System.Design.dll</Reference> | |
<Reference><RuntimeDirectory>\System.Runtime.Serialization.dll</Reference> | |
<Reference><RuntimeDirectory>\System.ServiceModel.Activation.dll</Reference> | |
<Reference><RuntimeDirectory>\System.ServiceModel.dll</Reference> | |
<Reference><RuntimeDirectory>\System.Web.ApplicationServices.dll</Reference> | |
<Reference><RuntimeDirectory>\System.Web.dll</Reference> | |
<Reference><RuntimeDirectory>\System.Web.Extensions.dll</Reference> | |
<Reference><RuntimeDirectory>\System.Web.Services.dll</Reference> | |
<Reference><RuntimeDirectory>\System.Windows.Forms.dll</Reference> | |
<NuGetReference>sdmap.ext</NuGetReference> | |
<Namespace>LINQPad.Controls</Namespace> | |
<Namespace>sdmap.ext</Namespace> | |
<Namespace>sdmap.Functional</Namespace> | |
<Namespace>System.Web.Script.Serialization</Namespace> | |
</Query> | |
var sdmapFolderTextbox = new TextBox(@"C:\Users\flysha.zhou\Desktop\sdmap-folder"); | |
var confirmFolderButton = new Button("Confirm"); | |
var statusContainer = new DumpContainer(); | |
Util.HorizontalRun(true, sdmapFolderTextbox, confirmFolderButton, statusContainer).Dump("sdmap folder: "); | |
var sdmapIdTextbox = new TextBox("Chat.GetRecentSession"); | |
var queryObjectBox = new TextArea("{QueryObject: 'here'}"); | |
var idConfirmButton = new Button("Generate SQL") { Visible = false}; | |
var sdmapIdContainer = new DumpContainer().Dump("sdmap Id: "); | |
sdmapIdContainer.Content = Util.HorizontalRun(true, sdmapIdTextbox, queryObjectBox, idConfirmButton); | |
var sqlContainer = new DumpContainer(); | |
var queryObjectInfoBox = new DumpContainer(); | |
Util.HorizontalRun(true, sqlContainer, queryObjectInfoBox).Dump("Generated SQL: "); | |
ISdmapEmiter emiter = null; | |
confirmFolderButton.Click += (o, e) => | |
{ | |
var sw = Stopwatch.StartNew(); | |
emiter = FileSystemSqlEmiter.FromSqlDirectoryAndWatch(sdmapFolderTextbox.Text, true); | |
statusContainer.Content = $"Compile successfully in {sw.Elapsed.TotalMilliseconds:F2}ms."; | |
idConfirmButton.Visible = true; | |
}; | |
idConfirmButton.Click += (o, e) => | |
{ | |
if (emiter == null) statusContainer.Content = "Please compile the sdmap folder!"; | |
var queryObject = new JavaScriptSerializer().DeserializeObject(queryObjectBox.Text); | |
try | |
{ | |
queryObjectInfoBox.Content = queryObject; | |
var sw = Stopwatch.StartNew(); | |
string sql = emiter.Emit(sdmapIdTextbox.Text, queryObject); | |
sqlContainer.Content = sql; | |
sw.Stop(); | |
statusContainer.Content = $"Generate successfully in {sw.Elapsed.TotalMilliseconds:F2}ms."; | |
} | |
catch (ResultFailedException ex) | |
{ | |
statusContainer.Content = ex; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment