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


C# BsonArray.AddRange方法代码示例

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


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

示例1: TestAddRangeDateTimeNull

 public void TestAddRangeDateTimeNull()
 {
     var array = new BsonArray();
     var values = (DateTime[])null;
     array.AddRange(values);
     Assert.AreEqual(0, array.Count);
 }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:7,代码来源:BsonArrayTests.cs

示例2: TestAddRangeInt32Null

 public void TestAddRangeInt32Null()
 {
     var array = new BsonArray();
     var values = (int[])null;
     array.AddRange(values);
     Assert.AreEqual(0, array.Count);
 }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:7,代码来源:BsonArrayTests.cs

示例3: TestAddRangeBooleanNull

 public void TestAddRangeBooleanNull()
 {
     var array = new BsonArray();
     var values = (bool[])null;
     array.AddRange(values);
     Assert.AreEqual(0, array.Count);
 }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:7,代码来源:BsonArrayTests.cs

示例4: GetAllChildren

 /// <summary>
 /// 获取角色下所有角色
 /// </summary>
 /// <param name="RoleId">角色Id</param>
 /// <returns>返回所有角色集合</returns>
 public BsonArray GetAllChildren(ObjectId RoleId)
 {
     BsonArray RoleList = new BsonArray();
     List<BsonDocument> RoleDoc = dh.GetAllData("userroles", new BsonDocument { { "PUserRole", RoleId } });
     foreach (BsonDocument Role in RoleDoc)
     {
         UserRole ur = new UserRole(Role);
         ur.UserRolePowers = ups.GetAll(ur.UserRolePowers);
         RoleList.AddRange(GetAllChildren(ur.Id));
         RoleList.Add(ur.ToBsonDocument());
     }
     return RoleList;
 }
开发者ID:Zane0816,项目名称:Mail-.Net,代码行数:18,代码来源:UserRoleServer.cs

示例5: ToBson

        public BsonDocument ToBson()
        {
            // Standard values
            BsonDocument doc = new BsonDocument
            {
                { "name", this.NAME },
                { "username", this.USERNAME },
                { "time_start", this.TIMESTART },
                { "time_end", this.TIMEEND },
            };

            var hash = HashParameters();

            foreach (var entry in hash)
            {
                if (entry.Value.Count > 1)
                {
                    var array = new BsonArray();
                    array.AddRange(entry.Value);

                    doc.Add(new BsonElement(entry.Key, array));
                }
                else if (entry.Value.Count == 1)
                {
                    int intValue;
                    if (int.TryParse(entry.Value[0], out intValue))
                    {
                        doc.Add(entry.Key, intValue);
                    }
                    else
                    {
                        DateTime dt;
                        if (DateTime.TryParse(entry.Value[0], out dt))
                        {
                            doc.Add(entry.Key, dt);
                        }
                        else
                        {
                            doc.Add(entry.Key, entry.Value[0]);
                        }
                    }
                }
            }

            return doc;
        }
开发者ID:jantza,项目名称:ssrs-mongo,代码行数:46,代码来源:ReportUsageItem.cs

示例6: ToMatchDocument

        public static BsonDocument ToMatchDocument(this MatchDefinition source)
        {
            var result = new BsonDocument();
            var matchFilterElements = new List<BsonElement>();
            source.Filters.Where(x=>x.AvailableFilterValues.Any(y=>y.Active)).ToList().ForEach(f =>
            {
                var colDoc = new BsonDocument();
                var selectedValues = new BsonArray();
                var selectedFilterValues = f.AvailableFilterValues.Where(x=>x.Active).Select(x => x.Value).Select(x => new BsonString(x)).ToList();
                selectedValues.AddRange(selectedFilterValues);
                //var itemE
                var itemElm = new BsonElement("$in", selectedValues);
                colDoc.Add(itemElm);
                var colElm = new BsonElement(f.Column.ColumnName, colDoc);
                matchFilterElements.Add(colElm);
            });
            var elementsDoc = new BsonDocument();
            elementsDoc.AddRange(matchFilterElements);

            var matchElement = new BsonElement("$match", elementsDoc);
            result.Add(matchElement);
            return result;
        }
开发者ID:cmcginn,项目名称:Akron,代码行数:23,代码来源:QueryBuilderExtensions.cs

示例7: createRole

 /// <summary>
 ///     添加自定义角色
 /// </summary>
 public static CommandResult createRole(MongoDatabase mongoDb, Role role)
 {
     var mongoCmd = new CommandDocument("createRole", role.Rolename);
     var privileges = new BsonArray();
     privileges.AddRange(role.Privileges.Select(x => x.AsBsonDocument()));
     mongoCmd.Add("privileges", privileges);
     var roles = new BsonArray();
     roles.AddRange(role.Roles.Select(x => x.AsBsonValue()));
     mongoCmd.Add("roles", roles);
     return ExecuteMongoDBCommand(mongoCmd, mongoDb);
 }
开发者ID:magicdict,项目名称:MongoCola,代码行数:14,代码来源:DataBaseCommand.cs

示例8: updateUser

 /// <summary>
 ///     修改用户(完全替换)
 /// </summary>
 /// <param name="user"></param>
 /// <param name="db"></param>
 /// <returns></returns>
 public static CommandResult updateUser(MongoUserEx user, MongoDatabase db)
 {
     var mongoCmd = new CommandDocument { { "updateUser", user.Username } };
     mongoCmd.Add("pwd", user.Password);
     var roles = new BsonArray();
     roles.AddRange(user.Roles.Select(x => x.AsBsonValue()));
     mongoCmd.Add("roles", roles);
     if (user.customData != null)
     {
         mongoCmd.Add("customData", user.customData);
     }
     return ExecuteMongoDBCommand(mongoCmd, db);
 }
开发者ID:magicdict,项目名称:MongoCola,代码行数:19,代码来源:DataBaseCommand.cs

示例9: TestAddRangeObjectIdNull

 public void TestAddRangeObjectIdNull()
 {
     var array = new BsonArray();
     var values = (ObjectId[])null;
     array.AddRange(values);
     Assert.AreEqual(0, array.Count);
 }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:7,代码来源:BsonArrayTests.cs

示例10: TestAddRangeIEnumerableNull

 public void TestAddRangeIEnumerableNull()
 {
     var array = new BsonArray();
     var values = (object[])null;
     array.AddRange(values);
     Assert.AreEqual(0, array.Count);
 }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:7,代码来源:BsonArrayTests.cs

示例11: TestAddRangeStringNull

 public void TestAddRangeStringNull()
 {
     var array = new BsonArray();
     var values = (string[])null;
     Assert.Throws<ArgumentNullException>(() => { array.AddRange(values); });
 }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:6,代码来源:BsonArrayTests.cs

示例12: TestAddRangeIEnumerableNull

 public void TestAddRangeIEnumerableNull()
 {
     var array = new BsonArray();
     var values = (object[])null;
     Assert.Throws<ArgumentNullException>(() => { array.AddRange(values); });
 }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:6,代码来源:BsonArrayTests.cs

示例13: DoFindUsers

        /// <summary>
        /// Finds the list of users that match the criteria.
        /// </summary>
        /// <param name="filter">Filters the results to only users that match.</param>
        /// <param name="tablesorterMetadata">The tablesorter metadata.</param>
        /// <returns>
        /// The list of users that match the criteria.
        /// </returns>
        protected override UserList DoFindUsers(UserSearchCriteria filter, TablesorterMetadata tablesorterMetadata = null)
        {
            MongoCollection<BsonDocument> collection = this.database.GetCollection(iApplyDb.UserAccess._COLLECTION_NAME);

            QueryDocument outerQuery = new QueryDocument();
            List<IMongoQuery> orQueries = new List<IMongoQuery>();

            if (filter.OrganisationIds != null && filter.OrganisationIds.Any())
            {
                orQueries.AddRange(filter.OrganisationIds.Select(organisationId => Query.Exists(string.Format("{0}.{1}", iApplyDb.UserAccess.ORGANISATIONS, organisationId))));
            }

            if (filter.IncludeNoOrganisationUsers)
            {
                orQueries.Add(Query.NotExists(iApplyDb.UserAccess.ORGANISATIONS));
                orQueries.Add(Query.EQ(iApplyDb.UserAccess.ORGANISATIONS, new BsonDocument()));
            }

            if (!filter.IncludeServiceUsers)
            {
                outerQuery.AddRange(Query.NE(iApplyDb.UserAccess.ACCOUNT_TYPE, new BsonString(AccountType.Service.ToString())).ToBsonDocument());
            }

            if (filter.RoleIds != null && filter.RoleIds.Any())
            {
                orQueries.AddRange(filter.RoleIds.Select(roleId => Query.Exists(string.Format("{0}.{1}", iApplyDb.UserAccess.ROLES, roleId))));
            }

            IMongoQuery subQuery;
            if (orQueries.Count > 0)
            {
                subQuery = Query.Or(orQueries);
                outerQuery.AddRange(subQuery.ToBsonDocument());
            }

            if (filter.UserIds != null && filter.UserIds.Any())
            {
                BsonArray bsonUserIds = new BsonArray();
                bsonUserIds.AddRange(filter.UserIds.Select(u => new BsonObjectId(new ObjectId(u))));
                subQuery = Query.In(iApplyDb.UserAccess._ID, bsonUserIds);
                outerQuery.AddRange(subQuery.ToBsonDocument());
            }

            if (filter.Usernames != null && filter.Usernames.Any())
            {
                BsonArray bsonUserNames = new BsonArray();
                bsonUserNames.AddRange(filter.Usernames.Select(u => new BsonString(u)));
                subQuery = Query.In(iApplyDb.UserAccess.USERNAME, bsonUserNames);
                outerQuery.AddRange(subQuery.ToBsonDocument());
            }

            if (filter.ExternalIds != null && filter.ExternalIds.Any())
            {
                BsonArray bsonExternalIds = new BsonArray();
                bsonExternalIds.AddRange(filter.ExternalIds.Select(u => new BsonString(u)));
                subQuery = Query.In(iApplyDb.UserAccess.EXTERNAL_ID, bsonExternalIds);
                outerQuery.AddRange(subQuery.ToBsonDocument());
            }

            if (tablesorterMetadata != null && tablesorterMetadata.SearchFilters != null)
            {
                for (int i = 0; i < tablesorterMetadata.SearchFilters.Length; i++)
                {
                    var fieldName = tablesorterMetadata.HeaderList[i];
                    var searchTerm = tablesorterMetadata.SearchFilters[i];

                    if (string.IsNullOrWhiteSpace(fieldName) || string.IsNullOrWhiteSpace(searchTerm))
                    {
                        continue;
                    }

                    subQuery = Query.EQ(fieldName, new BsonRegularExpression(searchTerm.Trim(), "i"));
                    outerQuery.AddRange(subQuery.ToBsonDocument());
                }
            }

            MongoCursor<BsonDocument> documents = collection.Find(outerQuery);
            if (tablesorterMetadata != null)
            {
                tablesorterMetadata.TotalRows = Convert.ToInt32(collection.Count(outerQuery));
                documents.SetSkip(tablesorterMetadata.PageSize * tablesorterMetadata.PageIndex).SetLimit(tablesorterMetadata.PageSize);

                if (tablesorterMetadata.SortOrder != null)
                {
                    SortByBuilder newSortByBuilder = new SortByBuilder();
                    foreach (int[] sortCriteria in tablesorterMetadata.SortOrder)
                    {
                        var columnNum = sortCriteria[0];
                        var sortOrder = sortCriteria[1];
                        if (sortOrder == 1)
                        {
                            newSortByBuilder.Descending(tablesorterMetadata.HeaderList[columnNum]);
//.........这里部分代码省略.........
开发者ID:cgavieta,项目名称:WORKPAC2016-poc,代码行数:101,代码来源:MongoDataAccess.Security.cs

示例14: GetActionArray

 /// <summary>
 ///     GetActionArray
 /// </summary>
 /// <param name="actionList"></param>
 /// <returns></returns>
 public static BsonArray GetActionArray(List<string> actionList)
 {
     var result = new BsonArray();
     result.AddRange(actionList);
     return result;
 }
开发者ID:magicdict,项目名称:MongoCola,代码行数:11,代码来源:MongoAction.cs


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