New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auditing Where extension method throws exception #653
Comments
I also experienced the issue on EF Core 3.1.10 (latest before 5) and equivalent EF Plus version (3.1.2). |
Thank you for the project @nwhittle , We will look at it. Best Regards, Jon Performance Libraries Runtime Evaluation |
Hello @nwhittle , Sorry for the long waiting, Unfortunately retrieving the audit with the See: https://entityframework-plus.net/ef-core-audit-retrieve-audit-entries-for-specific-item You can either pass an item or the key: using (var ctx = new TestContext())
{
ctx.AuditEntries.Where(item);
ctx.AuditEntries.Where<Entity_Basic>(item.ID);
ctx.AuditEntries.Where<Entity_Basic>(101);
} If you wish to return all items for a specific type, here is an online example: https://dotnetfiddle.net/bZdD0q var customers = context.AuditEntries.Where(x => x.State == AuditEntryState.EntityAdded && x.EntityTypeName == "Customer").ToList(); (I also added the Let me know if that helped you. Best Regards, Jon |
Hi @JonathanMagnan, Thank you for your reply. My goal (as you correctly determined) was to retrieve all entries for a type without retrieving any of that type's entities from the database first, so the first link you provided doesn't seem relevant for my use case. I initially wrote a query like the one you suggested to accomplish my goal, but then I went to use the generic type argument I had available, i.e:
I concluded that this must be the incorrect way to query the entries by type because EF Plus sets the I believe this is the primary reason I expected the generic Since I seem to have found an alternative which allows me to continue using the auditing feature (although my code won't be as concise), I consider myself unblocked and will continue using EF Plus for my project. Perhaps I could provide some feedback, given my thought process when learning the EF Plus api:
I will leave the issue open in case my feedback should be represented as an open issue. If this is not appropriate I can close it since I am unblocked. Thanks, Nathan |
Description
I am unable retrieve audit entries for a generic type using the
Where<T>()
extension method.Exception
Fiddle or Project
https://dotnetfiddle.net/bEDZTU
Further technical details
The text was updated successfully, but these errors were encountered: