Created
May 3, 2011 00:41
-
-
Save SamSaffron/952637 to your computer and use it in GitHub Desktop.
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
var q1 = System.Data.Linq.CompiledQuery.Compile( | |
(DBContext db, Badge bg, int pg) => | |
( | |
from u2b in db.Users2Badges | |
join b in db.Badges on u2b.BadgeId equals b.Id | |
from post in db.Posts.Where(p => p.Id == u2b.ReasonId && b.BadgeReasonType == BadgeReasonType.Post && p.DeletionDate == null).DefaultIfEmpty() | |
from tag in db.Tags.Where(t => t.Id == u2b.ReasonId && b.BadgeReasonType == BadgeReasonType.Tag).DefaultIfEmpty() | |
where u2b.BadgeId == b.Id | |
orderby u2b.Date descending | |
select new StackOverflow.ViewModel.BadgesViewModel.BadgeInfo | |
{ | |
Users2Badge = u2b, | |
Post = post, | |
Tag = tag, | |
User = u2b.User, | |
Badge = bg | |
} | |
).Skip((pg - 1)*60).Take(60) | |
); | |
var q2 = System.Data.Linq.CompiledQuery.Compile( | |
(DBContext db, Badge bg) => | |
( | |
from u2b in db.Users2Badges | |
join b in db.Badges on u2b.BadgeId equals b.Id | |
from post in db.Posts.Where(p => p.Id == u2b.ReasonId && b.BadgeReasonType == BadgeReasonType.Post && p.DeletionDate == null).DefaultIfEmpty() | |
from tag in db.Tags.Where(t => t.Id == u2b.ReasonId && b.BadgeReasonType == BadgeReasonType.Tag).DefaultIfEmpty() | |
where u2b.BadgeId == b.Id | |
orderby u2b.Date descending | |
select new StackOverflow.ViewModel.BadgesViewModel.BadgeInfo | |
{ | |
Users2Badge = u2b, | |
Post = post, | |
Tag = tag, | |
User = u2b.User, | |
Badge = bg | |
} | |
).Count() | |
); | |
q1(Current.DB, badge,1); | |
q2(Current.DB, badge); | |
using (Current.MiniProfiler.Step("test1")) | |
{ | |
q1(Current.DB, badge, 1); | |
q2(Current.DB, badge); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment