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

Entity mapping from mutilple query #20701

Closed
jasonliaocn opened this issue Apr 21, 2020 · 1 comment
Closed

Entity mapping from mutilple query #20701

jasonliaocn opened this issue Apr 21, 2020 · 1 comment

Comments

@jasonliaocn
Copy link

in my project I have one entity mapping to mutilple query from sql like:

public DBSet<Report1> Report1{ get; set; }
public DBSet<Report2> Report2{ get; set; }
public DBSet<Report3> Report3{ get; set; }
public DBSet<Table1> Table1{ get; set; }
public DBQuery<MyReport> MyReport{ get; set; }

public async Task<MyReport> GetMyReport1(){
string mysql = "select R1 as A, R2 as B, R3 as C from table Report1 join Table1";
return await Context.MyReport.FromSqlRaw(mysql).FirstOrDefaultAsync();
}

public async Task<MyReport> GetMyReport2(){
string mysql = "select R4 as A, R5 as B,R6 as C from table Report2 join Table1";
return await Context.MyReport.FromSqlRaw(mysql).FirstOrDefaultAsync();
}

public async Task<MyReport> GetMyReport3(){
string mysql = "select R7 as A, R8 as B, R9 as C from table Report3 join Table1";
return await Context.MyReport.FromSqlRaw(mysql).FirstOrDefaultAsync();
}

above three Report tables have different column names and struct

Currently I use the solution from EF Core 3 DbQuery equivalent functionality

Expect to keep the object like DBQuery or some replacement in EFCore 3.1 or higher versions

@ajcvickers
Copy link
Member

Duplicate of #18719

@ajcvickers ajcvickers marked this as a duplicate of #18719 Apr 21, 2020
@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

2 participants