S
shapper
Hello,
I have the following code:
postBook.Leafs = (from p in database.Posts
let tags = p.PostsTags.Select(pt =>
pt.Tag).DefaultIfEmpty()
orderby p.UpdatedAt descending
where p.PostsTags.Where(pt => pt.Tag.Name ==
tag || tag == null).Count() != 0 && p.IsPublished == true
select new PostLeaf {
Post = p,
Tags = tags.ToList(),
TagsCSV = string.Join(", ", tags.Select(t =>
t.Name).ToArray())
}).ToPagedList(page.HasValue ? page.Value -
1 : 0, LogPageSize);
This code should get:
1. All published posts if tag is not provided;
2. All published posts associated to a tag if provided.
I am getting a problem. When tag is not provided (Case 1) I get all
published posts but the posts that are not associated to any tag are
not included.
How can I solve this problem?
Thanks,
Miguel
I have the following code:
postBook.Leafs = (from p in database.Posts
let tags = p.PostsTags.Select(pt =>
pt.Tag).DefaultIfEmpty()
orderby p.UpdatedAt descending
where p.PostsTags.Where(pt => pt.Tag.Name ==
tag || tag == null).Count() != 0 && p.IsPublished == true
select new PostLeaf {
Post = p,
Tags = tags.ToList(),
TagsCSV = string.Join(", ", tags.Select(t =>
t.Name).ToArray())
}).ToPagedList(page.HasValue ? page.Value -
1 : 0, LogPageSize);
This code should get:
1. All published posts if tag is not provided;
2. All published posts associated to a tag if provided.
I am getting a problem. When tag is not provided (Case 1) I get all
published posts but the posts that are not associated to any tag are
not included.
How can I solve this problem?
Thanks,
Miguel