Instantly share code, notes, and snippets.

Embed
What would you like to do?
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