I'm trying to make a query with a 3 conditions on a join. But I get an error. In the sql server it's working perfectly, but when I try to convert it to linq it's giving me an erro.
You can take a look below the error and the query.
Query:
var temp = _context .FavouriteVol .Join(_context.Favourites, fv => new { fv.EntityId, fv.CountryId, fv.EType }, f => new { f.EntityId, f.CountryId, f.EType }, (fv, f) => new { Favourites = f, FavouriteVol = fv }) .Where(u => u.Favourites.userId == userId) .Select(f => f.Favourites) .ToList(); Note: EntityId (int), CountryId (string), and EType (int)`. The problem is with the string. but I need filter also with the string, so any idea how can I do it.
Error:
The type arguments for method 'System.Linq.Queryable.Join(System.Linq.IQueryable, System.Collections.Generic.IEnumerable, System.Linq.Expressions.Expression>, System.Linq.Expressions.Expression>, System.Linq.Expressions.Expression>)' cannot be inferred from the usage.
Sql:
SELECT * FROM db.FavouriteVol FV INNER JOIN db.Favourite F On F.EType = FV.EType and F.CountryId = FV.CountryId and F.EType = FV.EType WHERE F.userId = 5 Any idea how can I fix this problem?
Thanks!!
EntityId,CountryId, andETypeproperties?EntityId(int),CountryId(string), andEType(int) any idea how to fix it? I can not change the types on the database.(=> new { fv.EntityId, fv.EType }, f => new { f.EntityId, f.EType },)I don't know why :sstring(eg. 'IRL') on the database. I know it's a little bit confuse but I didn't create this app. I just trying to fix a problem on it and I need it. I have no idea why doesn't work the condition with thestring. Any suggestion or something to try to get it working?