c# - Entity framework stored procedure - mapping complex properties -
i have edmx data store , trying execute stored procedure against it:
. . . customerdb.executestorequery<customer>("getcustomers", parameters).tolist(); the customer class has following structure
class customer { public int id { get; set; } . . . public address address { get; set; } } class address { public int id { get; set; } . . . public string postcode { get; set; } } now no matter do, address property null. have tried return result set in different formats, no matter null.
e.g.
select c.id, ..., a.postcode customer c inner join address on c.customerid = a.customerid c.customerid = @customerid or
select c.id, ..., a.postcode 'address.postcode' customer c inner join address on c.customerid = a.customerid c.customerid = @customerid or
select c.id, ..., a.postcode 'address_postcode' customer c inner join address on c.customerid = a.customerid c.customerid = @customerid but columns never picked up.
what doing wrong?
thanks.
i don't think can way. according msdn
each property of type:
• must have setter.
• must correspond primitive type in csdl.
• must correspond column name in resulting dbdatareader (the provider implementation determines whether column has same name property). if name of type's property not match field of dbdatareader, entity framework materializes default value of property if defined in conceptutal model.
your address complextype in csdl. think have construct object type can materialized executestorequery.
Comments
Post a Comment