c# - LINQ include multiple childs -
i have construction store databases metadata
public class database { public string connectionstring { get; set; } public virtual icollection<table> tables { get; set; } } public class table { public string tablename { get; set; } public virtual icollection<foreingkey> foreingkeys { get; set; } public virtual icollection<field> fields { get; set; } }
i retrieve database related info in 1 query linq can query tables , 1 kid entity databases
var qry = d in context.databases .include(x => x.tables.select( c => c.fields)) select d;
but, how can read 2 childs tables collection? this
var qry = d in context.databases .include(x => x.tables.include(t => t.fields).include(t => t.foreingkeys)) select d;
var qry = d in context.databases .include("tables.fields") .include("tables.foreingkeys") select d;
ef automatically include tables , include navigation properties in query.
c# linq entity-framework
No comments:
Post a Comment