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


C# ODataQueryOptions.ParseSelect方法代码示例

本文整理汇总了C#中ODataQueryOptions.ParseSelect方法的典型用法代码示例。如果您正苦于以下问题:C# ODataQueryOptions.ParseSelect方法的具体用法?C# ODataQueryOptions.ParseSelect怎么用?C# ODataQueryOptions.ParseSelect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ODataQueryOptions的用法示例。


在下文中一共展示了ODataQueryOptions.ParseSelect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Get

 public EdmEntityObject Get(string key, ODataQueryOptions queryOptions)
 {
     var cxt = queryOptions.Context;
     var entityType = cxt.ElementType as EdmEntityType;
     if (this.PermissionCheck != null && !this.PermissionCheck(MethodType.Get, entityType.Name))
     {
         throw new UnauthorizedAccessException();
     }
     var keyDefine = entityType.DeclaredKey.First();
     string cmdSql = "select {0} from [{1}] where [{2}][email protected]{2}";
     var cmdTxt = string.Format(cmdSql
         , queryOptions.ParseSelect()
         , cxt.Path.Segments[0].ToString()
         , keyDefine.Name);
     EdmEntityObject entity = new EdmEntityObject(entityType);
     using (DbAccess db = new DbAccess(this.ConnectionString))
     {
         db.ExecuteReader(cmdTxt,
             (reader) =>
             {
                 for (int i = 0; i < reader.FieldCount; i++)
                 {
                     reader.SetEntityPropertyValue(i, entity);
                 }
             },
             (par) => { par.AddWithValue("@" + keyDefine.Name, key.ChangeType(keyDefine.Type.PrimitiveKind())); },
             CommandType.Text);
     }
     return entity;
 }
开发者ID:maskx,项目名称:OData,代码行数:30,代码来源:SQLDataSource.cs

示例2: BuildSqlQueryCmd

        static string BuildSqlQueryCmd(ODataQueryOptions options, string target = "")
        {
            var cxt = options.Context;
            string table = target;
            if (string.IsNullOrEmpty(target))
                table = string.Format("[{0}]", cxt.Path.Segments[0].ToString());
            string cmdSql = "select {0} {1} from {2} {3} {4} {5} {6}";
            string top = string.Empty;
            string skip = string.Empty;
            string fetch = string.Empty;

            if (options.Count == null && options.Top != null)
            {
                if (options.Skip != null)
                {
                    skip = string.Format("OFFSET {0} ROWS", options.Skip.RawValue); ;
                    fetch = string.Format("FETCH NEXT {0} ROWS ONLY", options.Top.RawValue);
                    top = string.Empty;
                }
                else
                    top = "top " + options.Top.RawValue;
            }
            var cmdtxt = string.Format(cmdSql
                , top
                , options.ParseSelect()
                , table
                , options.ParseWhere()
                , options.ParseOrderBy()
                , skip
                , fetch);
            return cmdtxt;
        }
开发者ID:maskx,项目名称:OData,代码行数:32,代码来源:SQLDataSource.cs

示例3: BuildSqlQueryCmd

        static string BuildSqlQueryCmd(ODataQueryOptions options, string target = "")
        {
            var cxt = options.Context;
            string table = target;
            if (string.IsNullOrEmpty(target))
                table = string.Format("[{0}]", cxt.Path.Segments[0].ToString());

            string cmdTxt = string.Empty;
            if (options.Count == null && options.Top != null)
            {
                if (options.Skip != null)
                {
                    cmdTxt = string.Format(
            @"select t.* from(
            select ROW_NUMBER() over ({0}) as rowIndex,{1} from {2} {3}
            ) as t
            where t.rowIndex between {4} and {5}"
                     , options.ParseOrderBy()
                     , options.ParseSelect()
                     , table
                     , options.ParseWhere()
                     , options.Skip.Value + 1
                     , options.Skip.Value + options.Top.Value);
                }
                else
                    cmdTxt = string.Format("select top {0} {1} from {2} {3} {4}"
                        , options.Top.RawValue
                        , options.ParseSelect()
                        , table
                        , options.ParseWhere()
                        , options.ParseOrderBy());
            }
            else
            {
                cmdTxt = string.Format("select  {0}  from {1} {2} {3} "
                         , options.ParseSelect()
                         , table
                         , options.ParseWhere()
                         , options.ParseOrderBy());
            }
            return cmdTxt;
        }
开发者ID:maskx,项目名称:OData,代码行数:42,代码来源:SQL2008.cs


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