I am trying to make a lambda linq query with join to two tables but I cannot make it work. I already have the linq query
timologia = db.Timologio.Where(p => (p.Imerominia >= apoDate.Date && p.Imerominia <=
eosDate.Date.AddDays(1)) &&
(p.Xrisi == xrisi && p.Diasafistis == diasafistis) &&
(!p.IsYpodeigma.HasValue || !p.IsYpodeigma.Value)
.OrderByDescending(p => p.Imerominia).ToList();
now I want to put another variable but I must read it from another table.
I want to search for timologio.seiraId which seiraId is in the table SeiresTimologiou and from there I want to get the EmfanisiStoMydata which is a bit.
In SQL management I can get the results that I want with this code:
select g.Description, t.*
from Timologio t
join SeiraTimologiou g on g.Id = t.SeiraId
where g.EmfanisiStoMydata is not null
I found in stackoverflow this answer https://stackoverflow.com/a/2767742/7054211
but when I try to use it throws me an error
var query = db.Timologio
.Join(db.SeiraTimologiou,
timol => timol.SeiraId,
seira => seira.EmfanisiStoMydata
(timol, seira) => new { Timol = timol, Seira = seira })
.Where(previous query && (TimolAndSeira=> TimolAndSeira.SeiraTimologiou.EmfanisiStoMydata == 1 ));
The error that I have is
The type arguments for method 'Queryable.Join<TOuter, TInner, TKey, TResult>(IQueryable, IEnumerable, Expression<Func<TOuter, TKey>>, Expression<Func<TInner, TKey>>, Expression<Func<TOuter, TInner, TResult>>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
Can someone help me?