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
I think the documentation of the Keyless Types is too simple.
Things that are not currently documented:
ToQuery method with lambda
What is the currently recommended way to use Keyless Types?
How can keyless types be reused as efficiently as possible?
What are the (better described) limitations
query documentation
Currently the documentation only shows how to use the keyless types in conjunction with database views.
db.Database.ExecuteSqlRaw(
@"CREATE VIEW View_BlogPostCounts AS SELECT b.Name, Count(p.PostId) as PostCount FROM Blogs b JOIN Posts p on p.BlogId = b.BlogId GROUP BY b.Name");
But after several tests I am at the point where I think that this does not (no longer) work.
I have an example here that is very similar to (and based on) the blog post. Just not the posts per blog, but per user.
Unfortunately this ends in the following exception:
InvalidOperationException: The LINQ expression 'DbSet
.Select(u => new UserBlogStatsView(
u.Id,
DbSet
.Where(f => EF.Property<Nullable>(u, "Id") != null && EF.Property<Nullable>(u, "Id") == EF.Property<Nullable>(f, "PostedByUserId"))
.Count()
))
.Where(u0 => u0.UserId == 1)' 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.
So, this is a regression?
View reuse
The next point would be the combination of views in order to reuse a view as often as possible.
I've now tried various ways this might work by now, but the only one that worked was raw SQL - which I like to avoid.
When I try to register this in the ModelBinder, I get the following exception:
The following constructors had parameters that could not be bound to properties of the entity type: cannot bind 'statsView' in 'UserProfileView(int id, string userName, UserBlogStatsView statsView)'.
Here I am relatively sure that this is currently not supported - but it would be nice. But what is the idea of reusing views as often and easily as possible?
If I cannot load the views at the same time ina simple single query, can I at least load the views with multi queries (that refer to one or more entities at the same time)?
I think the documentation of the Keyless Types is too simple.
Things that are not currently documented:
query documentation
Currently the documentation only shows how to use the keyless types in conjunction with database views.
But how would this example look like if I simply used ToQuery instead of ToView?
My guess would be:
But after several tests I am at the point where I think that this does not (no longer) work.
I have an example here that is very similar to (and based on) the blog post. Just not the posts per blog, but per user.
Unfortunately this ends in the following exception:
So, this is a regression?
View reuse
The next point would be the combination of views in order to reuse a view as often as possible.
I've now tried various ways this might work by now, but the only one that worked was raw SQL - which I like to avoid.
When I try to register this in the ModelBinder, I get the following exception:
Here I am relatively sure that this is currently not supported - but it would be nice. But what is the idea of reusing views as often and easily as possible?
If I cannot load the views at the same time ina simple single query, can I at least load the views with multi queries (that refer to one or more entities at the same time)?
Currently I only get an exception that the query could not be translated.
So I would be very happy if the documentation on how to use keyless types better and more efficient would be extended.
The text was updated successfully, but these errors were encountered: