Skip to content
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

How to map a custom select or view to hierarchical structure? #24794

Closed
Liero opened this issue Apr 28, 2021 · 1 comment
Closed

How to map a custom select or view to hierarchical structure? #24794

Liero opened this issue Apr 28, 2021 · 1 comment

Comments

@Liero
Copy link

Liero commented Apr 28, 2021

I would like to get IQueryable of Blogs with Post included from similar query:

string sql= @"SELECT * FROM Blogs
INNER JOIN Posts on Blogs.BlogId = Posts.BlogId AND Author like 'Lier%'"

The reason is, that I need to be able to paginate the blogs like this

var query = dbContext.Set<Blog>().Include(b => b.Posts).FromSql??(sql)
  .Skip(pageIndex * pageSize).
  .Take(pageSize);

so I can't do the mapping in memory.

Is it possible to map flat dataset to a class hierarchy? If not, it is theoretically possible in future EF versions?


The entities are the standard Blog/Posts entities from the docs..

public class Blog {
   public int BlogId {get; set;}
   public List<Posts> Posts {get; set;}
}

public class Posts {
   public int PostId {get; set;}
   public int BlogId {get; set;}
   public Blog Blog {get; set;}
   public string Author {get; set;}
}
@smitpatel
Copy link
Member

Duplicate of #14525

@smitpatel smitpatel marked this as a duplicate of #14525 Apr 28, 2021
@ajcvickers ajcvickers modified the milestone: Backlog Apr 29, 2021
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants