当前位置: 首页>>代码示例>>C#>>正文


C# EdmVersion.ToEdmxVersion方法代码示例

本文整理汇总了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();
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:22,代码来源:MetadataUtils.cs

示例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));
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:23,代码来源:MetadataUtils.cs


注:本文中的EdmVersion.ToEdmxVersion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。