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
Since lazy loaded navigation properties are planned for a future version of EF Core, I'll consider them as a given here. I am looking for a feature similar to NHibernate's lazy loaded proxies. To be more specific:
I often want to set or read navigation properties and compare entities for equality. Example: if(post1.Blog == post2.Blog)
In the above line, post1 and post2 are already loaded, but post1.Blog and post2.Blog might not be. I want to be able to do the comparison above without loading post1.Blog and post2.Blog from the database - essentially, I want to compare the foreign keys, by using a Blog entity as a "proxy".
Here's another example: Blog b = post1.Blog;
post1.Blog may or may not have been loaded previously. If it was, b is a normal Blog. Otherwise, b is a proxy that has a primary key value but no property values. post2.Blog = b;
Doesn't require DB access. string s = b.URL;
If b isn't loaded yet, EF automatically gets b's property values from the DB, since one of them was requested.
The following workarounds are not satisfactory:
Splitting the Blog table into two entities (or, since table splitting isn't in EF Core yet, into two tables and two entities) - one that has only the primary key and one that has the properties. I am unable to hide this hack in such a way that I can program with it as if it were a single entity.
Letting the business logic know whether an entity is loaded or not. That would complicate my business logic. Also, primary keys and foreign keys are a DB concept that doesn't belong in business logic in the first place.
The text was updated successfully, but these errors were encountered:
This is one of those things that should just work and that enable a good code writing experience. The ORM is almost invisible. This is a must. Good one!
@Wain123#1387 is a completely different feature. This feature is about not lazy-loading an entity when not needed; #1387 is about lazy-loading non-navigation properties.
Since lazy loaded navigation properties are planned for a future version of EF Core, I'll consider them as a given here. I am looking for a feature similar to NHibernate's lazy loaded proxies. To be more specific:
I often want to set or read navigation properties and compare entities for equality. Example:
if(post1.Blog == post2.Blog)
In the above line, post1 and post2 are already loaded, but post1.Blog and post2.Blog might not be. I want to be able to do the comparison above without loading post1.Blog and post2.Blog from the database - essentially, I want to compare the foreign keys, by using a Blog entity as a "proxy".
Here's another example:
Blog b = post1.Blog;
post1.Blog may or may not have been loaded previously. If it was, b is a normal Blog. Otherwise, b is a proxy that has a primary key value but no property values.
post2.Blog = b;
Doesn't require DB access.
string s = b.URL;
If b isn't loaded yet, EF automatically gets b's property values from the DB, since one of them was requested.
The following workarounds are not satisfactory:
The text was updated successfully, but these errors were encountered: