Created
August 17, 2011 05:49
-
-
Save csainty/1150888 to your computer and use it in GitHub Desktop.
blog post - Compiled Queries
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
public class Repository { | |
private gReadieModelContext _Ctx = gReadieModelContext.Create(gReadieModelContext.ConnectionString); | |
public Func<gReadieModelContext, IEnumerable<Folder>> Query_FoldersWithUnreadPosts = | |
CompiledQuery.Compile((gReadieModelContext db) => db.Folders.Where(d => d.UnreadCount != 0).AsEnumerable()); | |
public IEnumerable<Folder> GetFoldersWithUnreadPosts() { | |
return Query_FoldersWithUnread(_Ctx); | |
} | |
} | |
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
public class Repository { | |
private gReadieModelContext _Ctx = gReadieModelContext.Create(gReadieModelContext.ConnectionString); | |
public Func<gReadieModelContext, string, IEnumerable<Folder>> Query_FoldersContainingPost = | |
CompiledQuery.Compile((gReadieModelContext db, string postId) => db.Folders.Where(d => d.Posts.Any(e => e.PostId == postId)).AsEnumerable()); | |
public IEnumerable<Folder> GetFoldersContainingPost(string postId) { | |
return Query_FoldersContainingPost(_Ctx, postId); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment