title: Linq query - Entity Framework (joining two tables)
body: <p>I have got problem with LINQ query. In table <code>towar</code> I would like to get <code>Kategorie.Nazwa</code></p>
  
  <p>Example in sql: <code>SELECT Kategorie.Nazwa FROM Towar INNER JOIN Kategorie ON Towar.Id_kat = Kategorie.Id_kat</code></p>
  
  <p><img src="https://i.stack.imgur.com/yUfit.png" alt="enter image description here"></p>
  
  <p>Here is my problem <code>.Where(p =&gt; category == null || p.Id_kat == category)</code> I need name of category but I have got number. I need this <code>p.Id_kat = SELECT Kategorie.Nazwa FROM Towar INNER JOIN Kategorie ON Towar.Id_kat = Kategorie.Id_kat</code> I using EntityFramework DbContext.</p>
  
  <pre><code>SomeView viewModel = new SomeView
                  {
                      Towar = repository.Towar
                      .Where(p =&gt; category == null || p.Id_kat == category)
                      .OrderBy(p =&gt; p.Id_tow)
                      .Skip((page - 1) * PageSize)
                      .Take(PageSize),
  
                      Kategorie = re.Kategorie
                      .OrderBy(p =&gt; p.Id_kat),
  
                      PagingInfo = new PagingInfo
                                          {
                                         CurrentPage = page,
                                         ItemsPerPage = PageSize,
                                         TotalItems = repository.Towar.Count()
  
                                          },
                      CurrentCategory = category
  
                                     };
                  return View(viewModel);
              }
  </code></pre>