Моя заявка имеет структуру:
namespace DomainModel.Abstract
{
public interface IContentItemsRepository
{
IQueryable<Content> ContentItems { get; }
IQueryable<Category> Categories { get; }
IQueryable<ContentCategory> ContentCategories { get; }
}
}
namespace DomainModel.Entities
{
[Table(Name = "Content")]
public class Content
{
[Column(IsPrimaryKey = true,
IsDbGenerated = true,
AutoSync = AutoSync.OnInsert)]
public int content_id { get; set; }
[Column]
public string type { get; set; } // article, video, recipe, tool
[Column]
public string title { get; set; }
...
namespace DomainModel.Entities
{
[Table(Name = "Content_Categories")]
public class ContentCategory
{
[Column(IsPrimaryKey = true,
IsDbGenerated = true,
AutoSync = AutoSync.OnInsert)]
public int content_category_id { get; set; }
[Column]
public int content_id { get; set; }
[Column]
public int category_id { get; set; }
...
namespace DomainModel.Entities
{
[Table(Name = "Categories")]
public class Category
{
[Column(IsPrimaryKey = true,
IsDbGenerated = true,
AutoSync = AutoSync.OnInsert)]
public int category_id { get; set; }
[Column]
public string category_name { get; set; }
[Column]
public string type { get; set; } //recipe,tool,other
[Column]
public int ordering { get; set; }
...
Я могу сделать это:
var articlesInCategory = _contentRepository.ContentItems
.Where(x => x.type == "article");
и получите список статей. Нет проблем.
Однако теперь мне нужно выбрать контент на основе категорий. Итак, мне нужно присоединить Content к ContentCategory к Category.
Понятия не имею, как это сделать. Любая помощь будет высоко ценится.
Спасибо.
EDIT:
Я думаю, что часть моей проблемы в том, что я даже не знаю, как назвать то, что я делаю, поэтому трудно это найти. Я даже делаю LINQ to SQL или LINQ to Entities, или это LINQ to Objects?