本文整理汇总了C#中EdmVersion.ToEdmxVersion方法的典型用法代码示例。如果您正苦于以下问题:C# EdmVersion.ToEdmxVersion方法的具体用法?C# EdmVersion.ToEdmxVersion怎么用?C# EdmVersion.ToEdmxVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EdmVersion
的用法示例。
在下文中一共展示了EdmVersion.ToEdmxVersion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UnwrapEdmxEnvelope
/// <summary>
/// Unwraps the <paramref name="envelope"/> Edmx envelope and returns the actual payload.
/// </summary>
/// <param name="envelope">The <see cref="XElement"/> reprsenting the Edmx envelope.</param>
/// <param name="edmVersion">The Edm Version for the edmx envelope.</param>
/// <returns>The payload that was wrapped by the Edmx envelope.</returns>
public static XElement UnwrapEdmxEnvelope(this XElement envelope, EdmVersion edmVersion)
{
ExceptionUtilities.CheckArgumentNotNull(envelope, "envelope");
Version edmxVersion = edmVersion.ToEdmxVersion();
XNamespace edmxNamespace = EdmxXNamespace(edmxVersion);
ExceptionUtilities.Assert(envelope.Name.Namespace == edmxNamespace && envelope.Name.LocalName == "Edmx", "Expected <edmx:Edmx> as the top-level element.");
XAttribute versionAttribute = envelope.Attribute(EdmxVersionAttributeName);
ExceptionUtilities.Assert(versionAttribute != null && versionAttribute.Value == edmxVersion.ToString(), "Edmx version attribute not valid.");
XElement dataServicesElement = envelope.Element(edmxNamespace + "DataServices");
ExceptionUtilities.Assert(dataServicesElement != null, "<DataServices> element not found.");
return dataServicesElement.Elements().Single();
}
示例2: WrapInEdmxEnvelope
/// <summary>
/// Wraps the specified <paramref name="payload"/> into and Edmx envelope.
/// </summary>
/// <param name="payload">The <see cref="XElement"/> payload to wrap.</param>
/// <param name="edmVersion">The Edm Version for the edmx envelope.</param>
/// <returns>
/// The Edmx wrapper that contains the <paramref name="payload"/>.
/// </returns>
public static XElement WrapInEdmxEnvelope(this XElement payload, EdmVersion edmVersion)
{
ExceptionUtilities.CheckArgumentNotNull(payload, "payload");
XAttribute metadataNamespaceAttr = null;
Version edmxVersion = edmVersion.ToEdmxVersion();
XNamespace edmxNamespace = EdmxXNamespace(edmxVersion);
return new XElement(edmxNamespace + "Edmx",
new XAttribute(XNamespace.Xmlns + "edmx", edmxNamespace),
new XAttribute(EdmxVersionAttributeName, edmxVersion.ToString()),
new XElement(edmxNamespace + "DataServices",
metadataNamespaceAttr,
payload));
}