Last active
January 12, 2016 21:24
-
-
Save sapiens/789c5068f63880dbc95e to your computer and use it in GitHub Desktop.
SqlFu3 in action
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
//selecting related assets from a view then processing each row | |
//into a RelatedItem which gets added to a result | |
//generated sql is | |
//select [Id],[Type],[Name],[ContextId] from [AssetUsagesView] | |
//where ((([AssetId] = @0) and ([ProjectId] = @1)) and [Category] in (@3,@4)) | |
using (var db = await _db.CreateAsync(cancel)) | |
{ | |
await db.QueryAndProcessAsync( | |
q => | |
q.From<AssetUsagesViewRow>() | |
.Where(d=>d.AssetId==input.AssetId && d.ProjectId==input.ProjectId.Value | |
&& new[] {LinkCategory.CmdTriggers.ToString(),LinkCategory.TriggerEvents.ToString()}.Contains(d.Category)) | |
.Select(d=>new AssetBasicInfo()) | |
, a => | |
{ | |
rez.Add(new RelatedItem(a)); | |
return true; | |
},cancel); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment