Simple.Data › Aliasing Child Table for Correct Mapping

27 views
Skip to first unread message

Ben Magyar

unread,
Sep 8, 2015, 5:02:22 PM9/8/15
to Simple.Data
I am having a bit of trouble getting the magic mapping from the Simple.Data query to some object graph to happen. 

I have two classes: 

MyEvent and MyMember
public class MyEvent
{
   
public Guid ID { get; set; }
    public List<MyMember> Members { get; set; }
}

public class MyMember
{
   
public String MemberName { get; set; }
}

And the query:
(List<MyEvent>)_db.MyEvent.All().With(_db.MyEvent.MyEventMember.As("Members"))

The query correctly returns everything in MyEvent however there are no linked members to any of the related objects (at least in the tests using the in-memory adapter). I thought in order to get the Members list populated I would have to alias the MyEventMember table to Members, but that did not seem to work. 

Any advice? 

Oscar Alejandro Amado Sarmiento

unread,
Sep 10, 2015, 12:42:52 PM9/10/15
to Simple.Data
Did you create the relation in de memory adapter? 

Try this with a real db, sometimes the memory adapter doesn´t work in cases like this.

I hope this help you

Ben Magyar

unread,
Sep 10, 2015, 2:21:51 PM9/10/15
to Simple.Data
I do have the relation on the in memory adapter, and it does populate a MyEventMember list in the returned SimpleQuery but doesn't seem to be doing the cast correctly. I'll try with an actual database, but I thought direct child mappings were supported with Simple.Data. 
Reply all
Reply to author
Forward
0 new messages