jonwagner / Insight.Database

Fast, lightweight .NET micro-ORM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support complex objects mapping

ezelans opened this issue · comments

I have a complex object like this:
Request
{
double Id {get; set;}
Language language {get; set;}
ILIst WebSites {get; set;}
}

On my repository I have this method:
GetSarasa(){
GetSqlConnection().QuerySqlAsync("SELECT * FROM Request INNER JOIN Language ON (...) INNER JOIN Website ON (...)
WHERE (...),
Parameters.Empty,
Query.Returns(Together<Request, WebSite>.Records)).ConfigureAwait(false)
}

And that method returns me Request with WebSites but I can't figure it out how to get the Language too.

Can you help me pls?

  • Dotnet version: [netcore5]
  • Database: [SQL Server]
  • Library version: [6.2.3]

An alternative is to use
Query.Returns(OneToOne<Request, Language>.Records).ThenChildren(Some<Websites>.Records))

But it will require that your query returns 2 result sets, something like:

SELECT * FROM Request INNER JOIN Language ON (...);

SELECT RequestId, * FROM Request INNER JOIN Website ON (...);

You can check in the wiki for the rules of mapping to parents

Yhea.... but I dont want to return 2 result set. I think that should be any way to fill an entire object with a single query.

Thanks !