如何列出实体字段名称? [英] how to list entity field names?
问题描述
我无法列出实体的字段名称,我可以从(IEntitySet)this.DataWorkspace.ApplicationData.Details.Properties ["myentity"].Value
获取实体我尝试对实体的细节遵循相同的逻辑,但是似乎没有Properties方法.
foreach(在EntityNames中为EntityName n).
{
Microsoft.LightSwitch.Model.IEntityType实体类型=
this.Application.Details.GetModel()
.GlobalItems
.OfType< Microsoft.LightSwitch.Model.IEntityType>()
.Single(e => e.Name.Equals(n.Name,StringComparison.Ordinal));foreach(entityType.Properties.Select(p => p.Name)中的字符串s).
.Except(PropertyNames
.where(pn => pn.EntityName.Equals(n))
.Select(pn => pn.Name)
.Union(entityType.NavigationProperties.Select(np => np.Name))))) //不是导航道具
{
PropertyName _propertyName =新的PropertyName();
_propertyName.Name = s;
_propertyName.EntityName = n;
}
}这是从以下位置剪切粘贴的:
Microsoft LightSwitch实体名称和属性自填表
I am unable to list the field names of the entity, I can get entity from (IEntitySet)this.DataWorkspace.ApplicationData.Details.Properties["myentity"].Value
I tried to follow same logic with the details of the entity but there seems to be no Properties method.
thanks in advance.
foreach (EntityName n in EntityNames)
{
Microsoft.LightSwitch.Model.IEntityType entityType =
this.Application.Details.GetModel()
.GlobalItems
.OfType<Microsoft.LightSwitch.Model.IEntityType>()
.Single(e => e.Name.Equals(n.Name, StringComparison.Ordinal));foreach (string s in entityType.Properties.Select(p => p.Name)
.Except(PropertyNames
.Where(pn => pn.EntityName.Equals(n))
.Select(pn => pn.Name)
.Union(entityType.NavigationProperties.Select(np => np.Name)))) //not nav props
{
PropertyName _propertyName = new PropertyName();
_propertyName.Name = s;
_propertyName.EntityName = n;
}
}This was cut and pasted from:
Microsoft LightSwitch Entity Names and Properties Self Populating Tables
这篇关于如何列出实体字段名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!