asp.net - Entity Framework 6 - Null value in nested query with select -
i facing problem in ef6. when execute query select return value. when add select returns null.
the code here:
the (w) not null here...
var list = db.x.include("y").include("z.w") .orderby(c => c.id) .skip(pagesize * page) .take(pagesize) .tolist(); here, w value null...
var list = db.x.include("y").include("z.w") .select(a => new { a.id, a.z}) .orderby(c => c.id) .skip(pagesize * page) .take(pagesize) .tolist(); please :)
update 1
public class academy { public int id { get; set; } [stringlength(255)] [index(isunique = true)] public string name { get; set; } public string logo { get; set; } [required] public owner owner { get; set; } public list<location> location { get; set; } } public class location { public int id { get; set; } public string latitude { get; set; } public string longitude { get; set; } public string city { get; set; } public string region { get; set; } public string neighborhood { get; set; } public string street { get; set; } public academy academy { get; set; } public list<stadium> stadiums { get; set; } public list<administrators> administrators { get; set; } public list<addition> addition { get; set; } public list<pricing> pricing { get; set; } public list<time_frame> timeframes { get; set; } [notmapped] public string details { { return (city + " - " + street); } } } public class pricing { public int id { get; set; } public double price { get; set; } public double? priceafteroffer { get; set; } public datetime? startdate { get; set; } public datetime? enddate { get; set; } public location location { get; set; } public players_capacity stadiumcapacity { get; set; } } public class players_capacity { public int id { get; set; } [stringlength(255)] [index(isunique = true)] public string capacity { get; set; } } var list = db.locations .select(a => new { a.id, a.city, a.region, a.street, a.latitude, a.longitude, a.pricing, a.academy }) .orderby(c => c.id) .skip(pagesize * page) .take(pagesize) .tolist(); the problem on players_capacity null
any additional data specified include ignored if query changes "shape", in case additional .select expression invalidates previous include terms ignored. same happens if groupby or groupjoin.
fortunately fix simple: explicitly specify y , z.w members in projection:
var list = db.x .select( x => new { x.id, x.z, x.y, x.z.w } ) .orderby( p => p.id ) .skip( pagesize * page ) .take( pagesize ) .tolist();
Comments
Post a Comment