we are using fluent API and I need to know how I can map it correctly so we can use ParentId instead of having to go through Parent entity. Is that possible? I know it can be done using EF Core so I was hoping for a similar solution.
public class Parent
{
public int Id {get;set;}
public ISet<Child> Children {get;set;}
}
public class Child{
public int Id {get;set;}
public int ParentId {get;set;}
public Parent Parent {get;set;}
}
public static void Main()
{
var dummyQuery = Enumerable.Empty<Child>();
//Want to do like this.
dummyQuery= dummyQuery.Where(c => c.ParentId == 80).ToArray();
//This will do a join to the parent table.
dummyQuery= dummyQuery.Where(c => c.Parent.Id == 80).ToArray();
}
public class ChildMap : ClassMapping<Child>
{
public ChildMap ()
{
Table("Children");
//how do I do here?
ManyToOne(x => x.Parent, map => map.Column("ParentId"));
}
}