我正在研究WCF,EntityFramework 6项目。我想获取实体元数据。当前,元数据赋予实体列表其实体名称无序的顺序。例如,
<EntityType Name="ABCAnalysis">
<Key>
<PropertyRef Name="Id"/>
</Key>
<Property Name="Id" xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation" p6:StoreGeneratedPattern="Identity" Nullable="false" Type="Edm.Guid"/>
<Property Name="ABCClassification" Type="Edm.String" Unicode="true" FixedLength="false" MaxLength="Max"/>
<Property Name="ABCDescription" Type="Edm.String" Unicode="true" FixedLength="false" MaxLength="Max"/>
</EntityType>
<EntityType Name="Translation">
<EntityType Name="Language">
<Key>
<PropertyRef Name="Id"/>
</Key>
<Property Name="Id" xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation" p6:StoreGeneratedPattern="Identity" Nullable="false" Type="Edm.Guid"/>
<Property Name="LanguageName" Type="Edm.String" Unicode="true" FixedLength="false" MaxLength="Max"/>
<Property Name="ISO" Type="Edm.String" Unicode="true" FixedLength="false" MaxLength="Max"/>
</EntityType>
<EntityType Name="AcademicTitle">
<Key>
<PropertyRef Name="Id"/>
</Key>
<Property Name="Id" xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation" p6:StoreGeneratedPattern="Identity" Nullable="false" Type="Edm.Guid"/>
<Property Name="AcademicTitleName" Type="Edm.String" Unicode="true" FixedLength="false" MaxLength="Max"/>
<Property Name="AcademicTitledescriptionMale" Type="Edm.String" Unicode="true" FixedLength="false" MaxLength="Max"/>
</EntityType>
<EntityType Name="Accountability">
<Key>
<PropertyRef Name="Id"/>
</Key>
<Property Name="Id" xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation" p6:StoreGeneratedPattern="Identity" Nullable="false" Type="Edm.Guid"/>
<Property Name="AccountabilityName" Type="Edm.String" Unicode="true" FixedLength="false" MaxLength="Max"/>
<Property Name="AccountabilityDescription" Type="Edm.String" Unicode="true" FixedLength="false" MaxLength="Max"/>
</EntityType>
就像您看到我的回复未按EntityType名称排序一样。它是随机的,我不知道为什么。
现在,我要按其实体名称对其进行排序。因为有一些遗留代码使用此元数据来创建一些列表。如果我可以对元数据输出进行排序,这将帮助我解决工作中的许多问题。
我对WCF和EF 6的了解不多,我不知道这是由于我对WCF或EF的错误实现而导致的。还是我需要在其他地方进行其他配置。
任何帮助或评论都将对您有所帮助。 (至少是找到解决方案的一种方法。)
如果下面的xml不清楚,我提到了WCF的默认响应。
<atom:title>Default</atom:title>
<collection href="ABCAnalysis">
<atom:title>ABCAnalysis</atom:title>
</collection>
<collection href="Translation">
<atom:title>Translation</atom:title>
</collection>
<collection href="Language">
<atom:title>Language</atom:title>
</collection>
<collection href="AcademicTitle">
<atom:title>AcademicTitle</atom:title>
</collection>
<collection href="Accountability">
<atom:title>Accountability</atom:title>
</collection>
我希望这样的结果,
<collection href="ABCAnalysis">
<atom:title>ABCAnalysis</atom:title>
</collection>
<collection href="AcademicTitle">
<atom:title>AcademicTitle</atom:title>
</collection>
<collection href="Accountability">
<atom:title>Accountability</atom:title>
</collection>
<collection href="Language">
<atom:title>Language</atom:title>
</collection>
<collection href="Translation">
<atom:title>Translation</atom:title>
</collection>