I have created Entity Framework for a model. I would like to access inner object and bind that inner object to a datagridview. I can access inner object but i cant set data property of datagridview to show this. Can any one please help me out Here the code I have two classes in EF. ItemMaster And Category.ItemMaster Contains Category Id.Category Contains Category Name. now in EF i can access Category Object like
public static List<ItemMaster> GetAllItemMasters()
{
using (var itemContext = new EntitiesContext())
{
var items = itemContext.ItemMasters.Include("Category").Where(p=> (p.IsDelete== null || p.IsDeleted.Value == false)).ToList();
return items;
}
now while binding to a datagridview i have only properties like categoryid in code behind i can access inner object like itemmaster.category.categoryname but i cant set data property of datagridview as category.categoryname. So can you please help me out
添加对您的命名空间的引用(如果需要),然后将该项目拆箱到父类中。
((MyClass)Container.DataItem).MyInnerClassObject.SomePropertyValue
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.