jonwagner / Insight.Database

Fast, lightweight .NET micro-ORM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Insight.Database [BindChildren] on subclass not working

ralphhbrown opened this issue · comments

I am using insight.database with my c# project. I Have a class that has a subclass. I am using an inner join in my SP to flatten and get my fields. However, I want some of the query result fields to map to my subclass. It's not working as I expected. I have tried using the BindChildren attribute on both parent and subclass separately, then at the same time, but none of these worked. The parent class maps properly but no values are assigned to the subclass properties. Can someone let me know what I am doing wrong?
See stackoverflow post for code sample
https://stackoverflow.com/questions/60910513/insight-database-bindchildren-on-subclass-not-working

From your example on SO, since this is a OneToOne mapping and not a parent -> child list mapping, you could use the definition of Recordset like so:

public interface IUserRepository
{
    [Recordset(0, typeof(User), typeof(UserGroup))]
    [Sql("spGetUserById")]
    User GetUserById(int userid);
}

There are a few more examples on the Result Structures topic of the Auto Interface Implementation page of the wiki.