You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.netCore Upgrade from 2.2 -> 3.0 has caused using Include to throw exceptions
General
I am having an issue with a piece of code that was working in 2.2 but now throws on 3.0 in that iterating over an IQueryable that was constructed with .Include causes an exception.
The LINQ expression 'LeftJoin<Transaction, Client, string, TransparentIdentifier<Transaction, Client>>(
outer: DbSet,
inner: DbSet,
outerKeySelector: (b) => Property(b, "Clientid"),
innerKeySelector: (c) => Property(c, "id"),
resultSelector: (o, i) => new TransparentIdentifier<Transaction, Client>(
Outer = o,
Inner = i
))' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync(). See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
To isolate the problem I removed and tried various combinations of the query statement:
The LINQ expression 'LeftJoin<Transaction, User, string, TransparentIdentifier<Transaction, User>>(
outer: DbSet,
inner: DbSet,
outerKeySelector: (b) => Property(b, "Userid"),
innerKeySelector: (p) => Property(p, "id"),
resultSelector: (o, i) => new TransparentIdentifier<Transaction, User>(
Outer = o,
Inner = i
))' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync(). See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
The LINQ expression 'LeftJoin<Transaction, User, string, TransparentIdentifier<Transaction, User>>(
outer: DbSet,
inner: DbSet,
outerKeySelector: (b) => Property(b, "Userid"),
innerKeySelector: (p) => Property(p, "id"),
resultSelector: (o, i) => new TransparentIdentifier<Transaction, User>(
Outer = o,
Inner = i
))' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync(). See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
The LINQ expression 'LeftJoin<Transaction, Client, string, TransparentIdentifier<Transaction, Client>>(
outer: DbSet,
inner: DbSet,
outerKeySelector: (b) => Property(b, "Clientid"),
innerKeySelector: (c) => Property(c, "id"),
resultSelector: (o, i) => new TransparentIdentifier<Transaction, Client>(
Outer = o,
Inner = i
))' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync(). See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
Removed both .Includes and added the Where clause back, but modified to not check for clientCode
Conclusion
The issue seems isolated to the .Include chaining. I tried searching all the documents on 3.0s release that I could for any changes to how .Include works but my search yielded no results. I have a hard time believing this is was an uncaught defect with 3.0 as .Includes are a pretty important feature, and there may have been some underlying framework changes that make the original use of .Include in my code erroneous.
What would I be doing wrong in 3.0 that would cause this?
Below are my Transaction, Client, and User classes
public class Transaction
{
[Key]
public string id { get; set; }
public DateTime Timestamp { get; set; }
public string ErrorMessage { get; set; } = string.Empty;
public decimal Amount { get; set; }
public User User { get; set; }
public Client Client { get; set; }
public Site Site { get; set; }
public string Status { get; set; }
public string Type { get; set; }
}
public class Player
{
[Key]
public string id { get; set; }
public string ClientDefinedAccountNumber { get; set; } = string.Empty;
public DateTime CreationDate { get; set; } = DateTime.MinValue;
public string CurrencyCode { get; set; } = string.Empty;
public string CountryCode { get; set; } = string.Empty;
}
public class Client
{
[Key]
public string id { get; set; }
public string ClientCode { get; set; } = string.Empty;
public string FriendlyName { get; set; } = string.Empty;
public string CurrencyCode { get; set; } = string.Empty;
}
The text was updated successfully, but these errors were encountered:
Issue Title
.netCore Upgrade from 2.2 -> 3.0 has caused using Include to throw exceptions
General
I am having an issue with a piece of code that was working in 2.2 but now throws on 3.0 in that iterating over an IQueryable that was constructed with .Include causes an exception.
Statement:
Exception:
To isolate the problem I removed and tried various combinations of the query statement:
Removed the Where clause:
Verdict: Exception
Removed the Where clause & Client Include
Verdict: Exception
Removed Where clause & User Include
Verdict: Exception
Removed both .Includes and added the Where clause back, but modified to not check for clientCode
Veridct: WORKS
Conclusion
The issue seems isolated to the .Include chaining. I tried searching all the documents on 3.0s release that I could for any changes to how .Include works but my search yielded no results. I have a hard time believing this is was an uncaught defect with 3.0 as .Includes are a pretty important feature, and there may have been some underlying framework changes that make the original use of .Include in my code erroneous.
What would I be doing wrong in 3.0 that would cause this?
Below are my Transaction, Client, and User classes
The text was updated successfully, but these errors were encountered: