Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Support for querying objects without keys #1862

Closed
Milestone
@mikary

Description

@mikary

Note: The feature tracked in this issue could help with using EF Core with database views. However, the feature is not limited to database views and its completion would not mean that every aspect of database view support has been implemented. See#827 for an overview of the areas where EF Core interacts with database views.


While theFromSql() method onDbSet<TEntity> can already be used to bootstrap raw queries which through standard LINQ composition end up projecting arbitrary types (i.e. types that are not mapped in the model), the method requires those queries to be rooted on a mapped typeTEntity.

E.g. assuming Product is an entity type and ProductListEntry is just an arbitrary CLR type that is not mapped in the mode, this works:

vardata=db.Set<Product>().FromSql("SELECT * FROM Product WHERE 1=1").Select(t=>newProductListEntry{Id=t.Id,Name=t.Name}).ToList();

But this doesn't:

vardata=db.Set<ProductListEntry>().FromSql("SELECT Id, Name FROM Product WHERE 1=1").ToList();

This item was used initially to track the ability to produce results from raw queries which cannot be expressed as a transformation over a knownTEntity and hence cannot be rooted on aDbSet<TEntity>.

In the end we decided to enable mapping "query types", latter renamed to "entities without keys" in the model, which allowed us to support a large portion of the important scenarios this was about. We are now using#10753 to track working with other non-scalar types without having to add them first to the model.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp