开发者

how to get number of columns in an entity, like datatable?

开发者 https://www.devze.com 2023-04-02 12:54 出处:网络
I am new to entity framework. I want to get the number of columns of an entity object just like the old Datatable technique. İs it possible ?

I am new to entity framework.

I want to get the number of columns of an entity object just like the old Datatable technique. İs it possible ?

For example ,开发者_JS百科 in standart Nortwind Database , For the Customers table how can I get number of columns from Customers class derived from EntityObject;

Thanks in advance.


I think you can do this using reflection

PropertyInfo[] propertyInfos;
propertyInfos = typeof(MyClass).GetProperties();
var numberCol = propertyInfos.Length;

instead MyClass you should use your entity class


You can find it by exploring the MetadataWorkspace http://msdn.microsoft.com/en-us/library/bb387116.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号