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 use include #705

Open
XxSu opened this issue Feb 11, 2024 · 2 comments
Open

how to use include #705

XxSu opened this issue Feb 11, 2024 · 2 comments

Comments

@XxSu
Copy link

XxSu commented Feb 11, 2024

how to use include.
I use code example :

var q = db.Query().From("SysUser");
//db.Statement
q.IncludeMany("UserRoles", db.Query("SysUserRole"),"Uid","Id");
var d1=  db.Get<SysUser>(q).ToList();

the table SysUserRole has one record ,but the d1 don't hava any list in the UserRoles propety
but if I use db.Get(q).ToList(); the result is right

@User00015
Copy link
Contributor

User00015 commented Feb 21, 2024

The problem is that .Include is not supported using Get<T>. Its a huge gotcha.

The author expects you to use some way to convert dynamic back into an object from the Get(q) in your example, typically via serialized json.

@won5572
Copy link

won5572 commented Apr 5, 2024

I use mapster for converting.

var test = pagedResult.Adapt<List<Test>>();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants