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


C# AList.ToArray方法代码示例

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


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

示例1: GetAllDocs

        /// <exception cref="Couchbase.Lite.CouchbaseLiteException"></exception>
        internal IDictionary<String, Object> GetAllDocs(QueryOptions options)
        {
            var result = new Dictionary<String, Object>();
            var rows = new AList<QueryRow>();
            if (options == null)
                options = new QueryOptions();

            var includeDeletedDocs = (options.GetAllDocsMode() == AllDocsMode.IncludeDeleted);
            var updateSeq = 0L;
            if (options.IsUpdateSeq())
            {
                updateSeq = GetLastSequenceNumber();
            }

            // TODO: needs to be atomic with the following SELECT
            var sql = new StringBuilder("SELECT revs.doc_id, docid, revid, sequence");
            if (options.IsIncludeDocs())
            {
                sql.Append(", json");
            }
            if (includeDeletedDocs)
            {
                sql.Append(", deleted");
            }
            sql.Append(" FROM revs, docs WHERE");

            if (options.GetKeys() != null)
            {
                if (options.GetKeys().Count() == 0)
                {
                    return result;
                }
                var commaSeperatedIds = JoinQuotedObjects(options.GetKeys());
                sql.Append(String.Format(" revs.doc_id IN (SELECT doc_id FROM docs WHERE docid IN ({0})) AND", commaSeperatedIds));
            }
            sql.Append(" docs.doc_id = revs.doc_id AND current=1");

            if (!includeDeletedDocs)
            {
                sql.Append(" AND deleted=0");
            }

            var args = new AList<String>();
            var minKey = options.GetStartKey();
            var maxKey = options.GetEndKey();
            var inclusiveMin = true;
            var inclusiveMax = options.IsInclusiveEnd();

            if (options.IsDescending())
            {
                minKey = maxKey;
                maxKey = options.GetStartKey();
                inclusiveMin = inclusiveMax;
                inclusiveMax = true;
            }
            if (minKey != null)
            {
                Debug.Assert((minKey is String));
                sql.Append((inclusiveMin ? " AND docid >= ?" : " AND docid > ?"));
                args.AddItem((string)minKey);
            }
            if (maxKey != null)
            {
                Debug.Assert((maxKey is string));
                sql.Append((inclusiveMax ? " AND docid <= ?" : " AND docid < ?"));
                args.AddItem((string)maxKey);
            }
            sql.Append(
                String.Format(" ORDER BY docid {0}, {1} revid DESC LIMIT ? OFFSET ?", 
                    options.IsDescending() ? "DESC" : "ASC", 
                    includeDeletedDocs ? "deleted ASC," : String.Empty
                )
            );
            args.AddItem(options.GetLimit().ToString());
            args.AddItem(options.GetSkip().ToString());

            Cursor cursor = null;
            var docs = new Dictionary<String, QueryRow>();
            try
            {
                cursor = StorageEngine.RawQuery(
                    sql.ToString(),
                    CommandBehavior.SequentialAccess,
                    args.ToArray()
                );

//                cursor.MoveToNext();

                var keepGoing = cursor.MoveToNext();
                while (keepGoing)
                {
                    var docNumericID = cursor.GetLong(0);

                    var includeDocs = options.IsIncludeDocs();

                    var docId = cursor.GetString(1);
                    var revId = cursor.GetString(2);
                    var sequenceNumber = cursor.GetLong(3);
                    byte[] json = null;
//.........这里部分代码省略.........
开发者ID:FireflyLogic,项目名称:couchbase-lite-net,代码行数:101,代码来源:Database.cs

示例2: ResultSetWithOptions

 internal Cursor ResultSetWithOptions(QueryOptions options)
 {
     if (options == null)
     {
         options = new QueryOptions();
     }
     // OPT: It would be faster to use separate tables for raw-or ascii-collated views so that
     // they could be indexed with the right Collation, instead of having to specify it here.
     var collationStr = string.Empty;
     if (Collation == ViewCollation.ASCII)
     {
         collationStr += " COLLATE JSON_ASCII";
     }
     else
     {
         if (Collation == ViewCollation.Raw)
         {
             collationStr += " COLLATE JSON_RAW";
         }
     }
     var sql = "SELECT key, value, docid, revs.sequence";
     if (options.IsIncludeDocs())
     {
         sql = sql + ", revid, json";
     }
     sql = sql + " FROM maps, revs, docs WHERE [email protected]";
     var argsList = new AList<string>();
     argsList.AddItem(Sharpen.Extensions.ToString(Id));
     if (options.GetKeys() != null)
     {
         sql += " AND key in (";
         var item = "@";
         foreach (object key in options.GetKeys())
         {
             sql += item;
             item = ", @";
             argsList.AddItem(ToJSONString(key));
         }
         sql += ")";
     }
     var minKey = options.GetStartKey();
     var maxKey = options.GetEndKey();
     var inclusiveMin = true;
     var inclusiveMax = options.IsInclusiveEnd();
     if (options.IsDescending())
     {
         minKey = maxKey;
         maxKey = options.GetStartKey();
         inclusiveMin = inclusiveMax;
         inclusiveMax = true;
     }
     if (minKey != null)
     {
         System.Diagnostics.Debug.Assert((minKey is string));
         sql += inclusiveMin ? " AND key >= @" : " AND key > @";
         sql += collationStr;
         argsList.AddItem(ToJSONString(minKey));
     }
     if (maxKey != null)
     {
         System.Diagnostics.Debug.Assert((maxKey is string));
         if (inclusiveMax)
         {
             sql += " AND key <= @";
         }
         else
         {
             sql += " AND key < @";
         }
         sql += collationStr;
         argsList.AddItem(ToJSONString(maxKey));
     }
     sql = sql + " AND revs.sequence = maps.sequence AND docs.doc_id = revs.doc_id ORDER BY key";
     sql += collationStr;
     if (options.IsDescending())
     {
         sql = sql + " DESC";
     }
     sql = sql + " LIMIT @ OFFSET @";
     argsList.AddItem(options.GetLimit().ToString());
     argsList.AddItem(options.GetSkip().ToString());
     Log.V(Database.Tag, "Query " + Name + ": " + sql);
     var cursor = Database.StorageEngine.RawQuery(sql, CommandBehavior.SequentialAccess, argsList.ToArray());
     return cursor;
 }
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:85,代码来源:View.cs

示例3: ResultSetWithOptions


//.........这里部分代码省略.........
     }
     // OPT: It would be faster to use separate tables for raw-or ascii-collated views so that
     // they could be indexed with the right Collation, instead of having to specify it here.
     var collationStr = string.Empty;
     if (Collation == ViewCollation.ASCII)
     {
         collationStr += " COLLATE JSON_ASCII";
     }
     else
     {
         if (Collation == ViewCollation.Raw)
         {
             collationStr += " COLLATE JSON_RAW";
         }
     }
     var sql = "SELECT key, value, docid, revs.sequence";
     if (options.IsIncludeDocs())
     {
         sql = sql + ", revid, json";
     }
     sql = sql + " FROM maps, revs, docs WHERE maps.view_id=?";
     var argsList = new AList<string>();
     argsList.AddItem(Sharpen.Extensions.ToString(Id));
     if (options.GetKeys() != null)
     {
         sql += " AND key in (";
         var item = "?";
         foreach (object key in options.GetKeys())
         {
             sql += item;
             item = ", ?";
             argsList.AddItem(ToJSONString(key));
         }
         sql += ")";
     }
     var startKey = ToJSONString(options.GetStartKey());
     var endKey = ToJSONString(options.GetEndKey());
     var minKey = startKey;
     var maxKey = endKey;
     var minKeyDocId = options.GetStartKeyDocId();
     var maxKeyDocId = options.GetEndKeyDocId();
     var inclusiveMin = true;
     var inclusiveMax = options.IsInclusiveEnd();
     if (options.IsDescending())
     {
         var min = minKey;
         minKey = maxKey;
         maxKey = min;
         inclusiveMin = inclusiveMax;
         inclusiveMax = true;
         minKeyDocId = options.GetEndKeyDocId();
         maxKeyDocId = options.GetStartKeyDocId();
     }
     if (minKey != null)
     {
         sql += inclusiveMin 
             ? " AND key >= ?" 
             : " AND key > ?";
         sql += collationStr;
         argsList.AddItem(minKey);
         if (minKeyDocId != null && inclusiveMin)
         {
             //OPT: This calls the JSON collator a 2nd time unnecessarily.
             sql += " AND (key > ? {0} OR docid >= ?)".Fmt(collationStr);
             argsList.AddItem(minKey);
             argsList.AddItem(minKeyDocId);
         }
     }
     if (maxKey != null)
     {
         if (inclusiveMax)
         {
             sql += " AND key <= ?";
         }
         else
         {
             sql += " AND key < ?";
         }
         sql += collationStr;
         argsList.AddItem(maxKey);
         if (maxKeyDocId != null && inclusiveMax)
         {
             sql += string.Format(" AND (key < ? {0} OR docid <= ?)", collationStr);
             argsList.AddItem(maxKey);
             argsList.AddItem(maxKeyDocId);
         }
     }
     sql = sql + " AND revs.sequence = maps.sequence AND docs.doc_id = revs.doc_id ORDER BY key";
     sql += collationStr;
     if (options.IsDescending())
     {
         sql = sql + " DESC";
     }
     sql = sql + " LIMIT ? OFFSET ?";
     argsList.AddItem(options.GetLimit().ToString());
     argsList.AddItem(options.GetSkip().ToString());
     Log.V(Database.Tag, "Query {0}:{1}", Name, sql);
     var cursor = Database.StorageEngine.RawQuery(sql, CommandBehavior.SequentialAccess, argsList.ToArray());
     return cursor;
 }
开发者ID:FireflyLogic,项目名称:couchbase-lite-net,代码行数:101,代码来源:View.cs


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