MicroLite-ORM / MicroLite

MicroLite ORM framework
microliteorm.wordpress.com
Apache License 2.0
85 stars 24 forks source link

How to map nested classes #467

Open frankiDotNet opened 7 years ago

frankiDotNet commented 7 years ago

I could not find anything about mapping calsses that contains sub classes.

[Table("TableA")]
public class ClassA{

[COLUMN("B_ID")]
public BId {get; set;}

[COLUMN("b")]
public ClassB b{get; set;}
}

[Table("TableB")]
public class ClassB{

[COLUMN("ID")]
public Int32 Id{get; set;}
}

How to get this e.g. with a join or how do I load class A with nested B objects, that could have relations like one to one or one to many ?

TrevorPilley commented 7 years ago

This isn't currently supported in MicroLite, it's something I'm considering for MicroLite 7.0 but for now you will need to do that additional fetch yourself (the upside is you can choose if & when that occurs) using the Include API

frankiDotNet commented 7 years ago

Ok, sorry for the late response, had to recover from the shock ;-) I didn't think about it is not possible in this way. Ok if I use includes, is it possible to log all db sql queries that are made(nlog). So that I can see what is really happening at db level? I know this question is not helping but do you have release date for the version 7? And will there be a breaking change in this behaviour?

TrevorPilley commented 7 years ago

All that happens is 2 or more individual queries are sent to the database server as a single request over a single connection and the results are returned in separate datasets which are then parsed into objects and made available to the caller.

As far as logging the traffic, queries aren't written to the log to avoid sensitive data being stored but you can use something like the profiler in MS SQL Server to see what requests are made.

TrevorPilley commented 7 years ago

There's no firm time frame for 7.0 at the moment, I'm finishing the OData 4.0 work in the WebApi extension before I pick up on 7.0.

There may well be breaking changes in 7.0 but those will be detailed in the release notes and on the blog once known.

frankiDotNet commented 7 years ago

Thanks for the reply and for the detailed information. I appreciate your project, and I try to avoid entity framework as long as I can, but need a good alternative. I think yours is getting more a really good one. Last thing before I close the issue (question). I asked about logging each sql query that is applied to the db, is this possible?

TrevorPilley commented 7 years ago

Not in MicroLite itself, the standard way to do that is with the profiling tools that are part of the database server e.g. SQL Server Profiler