在 oxite.LinqToSqlDataProvider 中的 PageRepository.cs
要 學起來
private IQueryable<Page> projectPages(IQueryable<oxite_Post> posts)
{
return from p in posts
join u in context.oxite_Users on p.CreatorUserID equals u.UserID
let c = getCommentsQuery(p.PostID)
where p.State != (byte)EntityState.Removed
orderby p.PublishedDate descending
select new Page
{
ID = p.PostID,
Parent = getParentPage(p),
HasChildren = getHasChildren(p),
Creator = new User
{
DisplayName = u.DisplayName,
Email = u.Email,
HashedEmail = u.HashedEmail,
ID = u.UserID,
LanguageDefault = new Language
{
ID = u.oxite_Language.LanguageID,
DisplayName = u.oxite_Language.LanguageDisplayName,
Name = u.oxite_Language.LanguageName
},
Name = u.Username,
Status = u.Status,
},
Body = p.Body,
BodyShort = p.BodyShort,
Comments = new LazyList<Comment>(c),
Created = p.CreatedDate,
Modified = p.ModifiedDate,
Published = p.PublishedDate,
Slug = p.Slug,
State = (EntityState)p.State,
Title = p.Title,
CommentingDisabled = p.CommentingDisabled
};
}
沒有留言:
張貼留言