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
When executing a query like _context.Bs.SingleOrDefault(x => x.Id == 'blabla'), I notice, when debugging very deeply, that the ID parameter is not being resolved on database side.
Immediately two concerns here:
Why am I not getting a warning that this is being evaluated on clientside
Why is Id not being resolved to the cosmos-db specific id field?
The reason why I added all those things just to map Id successfully, is because cosmos DB already has an 'id' property on a document. But I don't want to see 'id' as a public property as that's nasty, I wanted it camelcase. However, when first adding the camelcase Id that referenced the id field, the Id field was getting saved in the db as well, which is even crazier, we already have an id!
I'm thinking the NotMapped attribute is causing the property not being resolved.
This resolving is happening in the MemberAccessExpressionVisitor.GetPropertyPath, to be more precise, this piece of code returns null for the 'Id' property:
I'm thinking the NotMapped attribute is causing the property not being resolved.
That is the reason. Remove NotMapped. When you put NotMapped, you are effectively telling EF that don't store this property in database. When EF encounter such property in LINQ query, EF will materialize the whole object to run the query. Since it is in where predicate, it will fetch whole container data from server. Cosmos is still in preview and does not have enough logging to warn for client eval.
when first adding the camelcase Id that referenced the id field, the Id field was getting saved in the db as well, which is even crazier, we already have an id!
Use this modelBuilder.Entity<A>().Property(e => e.Id).Metadata.Cosmos().PropertyName = "id";
I'm thinking the NotMapped attribute is causing the property not being resolved.
That is the reason. Remove NotMapped. When you put NotMapped, you are effectively telling EF that don't store this property in database. When EF encounter such property in LINQ query, EF will materialize the whole object to run the query. Since it is in where predicate, it will fetch whole container data from server. Cosmos is still in preview and does not have enough logging to warn for client eval.
when first adding the camelcase Id that referenced the id field, the Id field was getting saved in the db as well, which is even crazier, we already have an id!
Use this modelBuilder.Entity<A>().Property(e => e.Id).Metadata.Cosmos().PropertyName = "id";
Thanks! Is it possible to use an annotation instead of doing this with the modelbuilder?
It's a base class so would save me many plumbing :)
I have an entity as follows;
When executing a query like
_context.Bs.SingleOrDefault(x => x.Id == 'blabla')
, I notice, when debugging very deeply, that the ID parameter is not being resolved on database side.Immediately two concerns here:
The reason why I added all those things just to map Id successfully, is because cosmos DB already has an 'id' property on a document. But I don't want to see 'id' as a public property as that's nasty, I wanted it camelcase. However, when first adding the camelcase Id that referenced the id field, the Id field was getting saved in the db as well, which is even crazier, we already have an id!
I'm thinking the NotMapped attribute is causing the property not being resolved.
This resolving is happening in the MemberAccessExpressionVisitor.GetPropertyPath, to be more precise, this piece of code returns null for the 'Id' property:
This is causing it to just download the whole collection and iterate in memory. Pretty fast I was getting throttled :(
Using the latest 2.2 release btw
The text was updated successfully, but these errors were encountered: