我遇到了 LINQ 查询的问题。在表中towar
我想得到Kategorie.Nazwa
sql中的示例:SELECT Kategorie.Nazwa FROM Towar INNER JOIN Kategorie ON Towar.Id_kat = Kategorie.Id_kat
这是我的问题.Where(p => category == null || p.Id_kat == category)
,我需要类别名称,但我有编号。我需要这个p.Id_kat = SELECT Kategorie.Nazwa FROM Towar INNER JOIN Kategorie ON Towar.Id_kat = Kategorie.Id_kat
我使用EntityFramework DbContext。
SomeView viewModel = new SomeView
{
Towar = repository.Towar
.Where(p => category == null || p.Id_kat == category)
.OrderBy(p => p.Id_tow)
.Skip((page - 1) * PageSize)
.Take(PageSize),
Kategorie = re.Kategorie
.OrderBy(p => p.Id_kat),
PagingInfo = new PagingInfo
{
CurrentPage = page,
ItemsPerPage = PageSize,
TotalItems = repository.Towar.Count()
},
CurrentCategory = category
};
return View(viewModel);
}