title: Search query with parameters in linq c#
body: <p>I need to build a search query with dynamic parameters in net core 3.0.</p>
  <pre><code>IQueryable&lt;UserDto&gt; query = 
  from user in dbContext.DB_USER
  join items in dbContext.DB__ITEMS on user.IdItem equals items.IdItem
  join cars in dbContext.DB_CARS on user.IdCars equals cars.IdItem
  join statsCar in dbContext.DB_STATS_CARS on cars.IdCars equals statsCar.Id
  select new UserDto
  {
      Id = user.Id,
      Name = user.Name,
      Data = user.Data.HasValue ? user.Data.Value.ToUnixTime() : default(long?),
      Lvl = user.L,
      Items = new ItemsUdo
      {
          Id = items.Id,
          Type = items.Type,
          Value = items.Value
      },
      Cars = new CarsDto
      {
          Id = cars.Id,
          Model = cars.model,
          Color = cars.Color
      }
  
  };
  </code></pre>
  <p>I would like to add search parameters like user name, items type, cars model and data from user. I tried to add &quot;where&quot; before 'select new UserDto' but not always user will provide all search parameters. If I give below:</p>
  <pre><code>if(fromSearch.UserName != null &amp;&amp; fromSearch.UserName.Lenght &gt; 0)
  {
      query = query.Where(u =&gt; u.Name == fromSearch.UserName);
  }
  </code></pre>
  <p>it works(on user.data does not work) but is it correct? How to do this in linq query?</p>