var articles = (from a in context.Articles
where a.Id != articleId
orderby a.Categories ??Name?? ascending
select a).ToList();
a.Categories is table (connected with many-many relation)
public EntityCollection<Category> Categories
{
get
{
return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<Category>("AsoModel.CategoryArticle", "Category");
}
set
{
if ((value != null))
{
((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<Category>("AsoModel.CategoryArticle", "Category", value);
}
}
}
How can i use ascending by Name on that Category table.
example:
Article name: Football and this article is in category Sport and News. So two tables are conected by many-many relationship. Now i want to order this article by category name and News is first, Sport is second…
1 Answer