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


C# EntityCollection.Add方法代码示例

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


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

示例1: TestIfPrimaryCallTypesFieldsAreBeingFilled

        public void TestIfPrimaryCallTypesFieldsAreBeingFilled()
        {
            // Arrange
            EntityCollection<CS_PrimaryCallType_CallType> primaryCallTypeReference = new EntityCollection<CS_PrimaryCallType_CallType>();
            primaryCallTypeReference.Add(
                new CS_PrimaryCallType_CallType()
                {
                    ID = 1,
                    PrimaryCallTypeID = 1,
                    CallTypeID = 1,
                    CS_CallType = new CS_CallType()
                    {
                        ID = 1,
                        Description = "Call Type 1",
                        Active = true
                    }
                });
            primaryCallTypeReference.Add(
                new CS_PrimaryCallType_CallType()
                {
                    ID = 2,
                    PrimaryCallTypeID = 1,
                    CallTypeID = 2,
                    CS_CallType = new CS_CallType()
                    {
                        ID = 2,
                        Description = "Call Type 2",
                        Active = true
                    }
                });
            CS_PrimaryCallType primaryCallTypeRepeaterDataItem = new CS_PrimaryCallType()
            {
                ID = 1,
                Type = "Primary Call Type",
                Active = true,
                CS_PrimaryCallType_CallType = primaryCallTypeReference
            };

            Mock<ICallCriteriaInfoView> view = new Mock<ICallCriteriaInfoView>();
            view.SetupProperty(m => m.PrimaryCallTypeRepeaterDataItem, primaryCallTypeRepeaterDataItem);
            view.SetupProperty(m => m.PrimaryCallTypeRepeaterRowDescription, string.Empty);
            view.SetupProperty(m => m.PrimaryCallTypeRepeaterRowCallTypeList, new List<CS_PrimaryCallType_CallType>());

            // Act
            CallCriteriaInfoPresenter presenter = new CallCriteriaInfoPresenter(view.Object);
            presenter.FillPrimaryCallTypeRow();

            // Assert
            Assert.AreEqual("Primary Call Type", view.Object.PrimaryCallTypeRepeaterRowDescription);
            Assert.AreEqual(2, view.Object.PrimaryCallTypeRepeaterRowCallTypeList.Count);
        }
开发者ID:danilocecilia,项目名称:HulcherProject,代码行数:51,代码来源:CallCriteriaInfoPresenterTest.cs

示例2: GetCollection

        public static EntityCollection GetCollection()
        {
            EntityCollection tempList = null;

            using (SqlConnection myConnection = new SqlConnection(AppConfiguration.ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("usp_GetEntity", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;
                    myCommand.Parameters.AddWithValue("@QueryId", SelectTypeEnum.GetCollection);
                    myConnection.Open();
                    using (SqlDataReader myReader = myCommand.ExecuteReader())
                    {
                        if (myReader.HasRows)
                        {
                            tempList = new EntityCollection();
                            while (myReader.Read())
                            {
                                tempList.Add(FillDataRecord(myReader));
                            }

                        }
                        myReader.Close();
                    }
                }
            }

            return tempList;
        }
开发者ID:justyBig,项目名称:OGAstonEngineer,代码行数:29,代码来源:EntityDAL.cs

示例3: LoadFromDatabase

        public static EntityCollection LoadFromDatabase(string connectionString)
        {
            var entities = new EntityCollection();

            var schemaInfo = DatabaseSchemaInfo.LoadFromDatabase(connectionString);
            foreach (var table in schemaInfo.Tables)
            {
                var entity = new Entity
                {
                    Name = table.Name,
                    Schema = table.Schema,
                    Database = table.Database
                };
                entities.Add(entity);

                foreach (var column in table.Columns)
                {
                    var member = new EntityMember
                    {
                        Name = column.Name,
                        DataType = DataTypeInfo.FromSqlDataTypeName(column.DataType, column.IsNullable),
                        MaxLength = column.MaxLength,
                        DecimalPlaces = column.DecimalPlaces,
                        IsNullable = column.IsNullable,
                        IsPrimaryKey = column.IsPrimaryKey,
                        IsIdentity = column.IsIdentity,
                        IsComputed = column.IsComputed,
                        OrdinalPosition = column.OrdinalPosition
                    };
                    entity.Members.Add(member);
                }
            }

            return entities;
        }
开发者ID:anilmujagic,项目名称:Insula,代码行数:35,代码来源:EntityLoader.cs

示例4: InsertArea1

 public Int64? InsertArea1(ForestArea forestArea, CadastralPoint[] cadastralPoints)
 {
     using (var db = new DefaultCS())
     {
         try
         {
             if (cadastralPoints != null)
             {
                 EntityCollection<CadastralPoint> cp = new EntityCollection<CadastralPoint>();
                 foreach (var cpp in cadastralPoints)
                 {
                     cp.Add(cpp);
                 }
                 forestArea.CadastralPoints1 = cp;
             }
             forestArea.CreatedDate = DateTime.Now;
             db.ForestAreas.AddObject(forestArea);
             db.SaveChanges();
             return forestArea.Id;
         }
         catch (Exception ex)
         {
             return null;
         }
     }
 }
开发者ID:saif859,项目名称:MAPS,代码行数:26,代码来源:AddArea.asmx.cs

示例5: GetjournalSum

 public List<decimal> GetjournalSum(int periodId, int typeid, int entityid)
 {
     using (RecordAccessClient _Client = new RecordAccessClient(EndpointName.RecordAccess))
     {
         if (typeid.Equals(2))
         {
            // Entity _entity =
             EntityAccessClient _enClient = new EntityAccessClient(EndpointName.EntityAccess);
             EntityCollection _accountcollection = new EntityCollection(_enClient.QueryAllSubEntity(entityid));
             List<decimal> _allandsub = new List<decimal>();
             decimal _base = 0;
             decimal _sgd = 0;
             _accountcollection.Add(_enClient.Query2(entityid)[0]);
             foreach (Entity _entity in _accountcollection)
             {
                 if (_Client.GetjournalSum(periodId, typeid, _entity.EntityID).ToList().Count > 0)
                 {
                     _base += _Client.GetjournalSum(periodId, typeid, _entity.EntityID).ToList()[0];
                     _sgd += _Client.GetjournalSum(periodId, typeid, _entity.EntityID).ToList()[1];
                 }
             }
             _allandsub.Add(_base);
             _allandsub.Add(_sgd);
             return _allandsub.ToList();
         }
         else
         {
             return _Client.GetjournalSum(periodId, typeid, entityid).ToList();
         }
     }
 }
开发者ID:WiseLinProject,项目名称:Projects,代码行数:31,代码来源:DataEntryService.svc.cs

示例6: entityCollectioin

 public static EntityCollection entityCollectioin(EntityCollection ec, EntityCollection entityCollection)
 {
     foreach (var entity in entityCollection)
     {
         ec.Add(entity);
         if (entity.SubEntities.Count() > 0)
             entityCollectioin(ec, entity.SubEntities);
     }
     return ec;
 }
开发者ID:WiseLinProject,项目名称:Projects,代码行数:10,代码来源:EntitiesFunc.cs

示例7: TestConcatOperator

        public void TestConcatOperator()
        {
            EntityCollection<TestAccountEntity> entities = new EntityCollection<TestAccountEntity>();
            entities.Add(new TestAccountEntity(100, 5));
            entities.Add(new TestAccountEntity(102, 8));

            EntityCollection<TestAccountEntity> entities0 = new EntityCollection<TestAccountEntity>();
            entities0.Add(new TestAccountEntity(103, 15));
            entities0.Add(new TestAccountEntity(104, 2));

            IEnumerable<TestAccountEntity> result = entities.Concat(entities0);

            Assert.IsNotNull(result);
            foreach (TestAccountEntity entity in result)
            {
                Assert.IsNotNull(entity);
                Console.WriteLine(entity);
            }
        }
开发者ID:abelperez,项目名称:csharp-commons,代码行数:19,代码来源:EntityCollectionTest.cs

示例8: TestAffiliateEntityCollection

        public void TestAffiliateEntityCollection()
        {
            TestEntity affiliate = new TestEntity();
            affiliate.Id = 1000;

            TestEntity affiliate0 = new TestEntity();
            affiliate0.Id = 1001;

            TestEntity affiliate1 = new TestEntity();
            affiliate1.Id = 1002;

            EntityCollection<TestEntity> collection = new EntityCollection<TestEntity>();
            collection.Add(affiliate);
            collection.Add(affiliate0);
            collection.Add(affiliate1);

            foreach (TestEntity aff in collection)
            {
                Console.WriteLine("Affiliate: {0}", aff.Id);
            }
        }
开发者ID:abelperez,项目名称:csharp-commons,代码行数:21,代码来源:EntityCollectionTest.cs

示例9: InsertArea

 public Int64? InsertArea(ForestArea forestArea, ForestCoordinate[] forestCoordinates)
 {
     using (var db = new DefaultCS())
     {
         try
         {
             EntityCollection<ForestCoordinate> fc = new EntityCollection<ForestCoordinate>();
             foreach (var fcc in forestCoordinates)
             {
                 fc.Add(fcc);
             }
             forestArea.ForestCoordinates = fc;
             forestArea.CreatedDate = DateTime.Now;
             db.ForestAreas.AddObject(forestArea);
             db.SaveChanges();
             return forestArea.Id;
         }
         catch (Exception ex)
         {
             return null;
         }
     }
 }
开发者ID:saif859,项目名称:MAPS,代码行数:23,代码来源:AddArea.asmx.cs

示例10: GetEntities

        public EntityCollection GetEntities(User user)
        {
            EntityCollection collection = new EntityCollection();
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand();
                command.Connection = connection;
                command.CommandText = "SP_Frank_TEST";

                SqlParameter ColumnParam = command.Parameters.Add("@User_ID", System.Data.SqlDbType.Int);
                ColumnParam.Value = user.UserID;
                command.CommandType = System.Data.CommandType.StoredProcedure;
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        Entity entity = new Entity();
                        entity.EntityID = Convert.ToInt32(reader["ID"]);
                        entity.EntityName = reader["Name"].ToString();
                        entity.EntityType = (EntityType)Convert.ToInt32(reader["Type"]);
                        entity.Currency.CurrencyID = reader["Currency"].ToString();
                        entity.ExchangeRate = Convert.ToDecimal(reader["Exchange_Rate"]);
                        entity.SumType = (SumType)Convert.ToInt32(reader["SumType"]);
                        collection.Add(entity);
                    }
                }
                return collection;
            }
        }
开发者ID:WiseLinProject,项目名称:Projects,代码行数:31,代码来源:LimitControl.svc.cs

示例11: GenerateEmailBodyForInvoicingTeamTest

        public void GenerateEmailBodyForInvoicingTeamTest()
        {
            DateTime dt = new DateTime(2011, 02, 14);

            TimeSpan timeSpan = new TimeSpan(10, 11, 59);

            CS_Country country = new CS_Country()
                                     {
                                         ID = 1,
                                         Active = true,
                                         Name = "USA"

                                     };

            CS_State state = new CS_State()
                                 {
                                     ID = 1,
                                     Active = true,
                                     Name = "Texas"
                                 };

            CS_City city = new CS_City()
                               {
                                   ID = 1,
                                   Active = true,
                                   Name = "Dalton"
                               };

            CS_LocationInfo locationInfo = new CS_LocationInfo()
                                            {
                                                Active = true,
                                                CountryID = 1,
                                                StateID = 1,
                                                CityID = 1,
                                                CS_Country = country,
                                                CS_State = state,
                                                CS_City = city
                                            };

            CS_Frequency frequency = new CS_Frequency()
                                         {
                                             Active = true,
                                             ID = 1,
                                             Description = "D"
                                         };

            CS_JobDescription csJobDescription = new CS_JobDescription()
            {
                Active = true,
                NumberEmpties = 1,
                NumberLoads = 2,
                NumberEngines = 1
            };

            CS_Division division = new CS_Division()
            {
                ID = 241,
                Active = true,
                Name = "005",
                Description = "White River, Ontario"
            };

            CS_JobDivision jobdivision = new CS_JobDivision()
            {
                Active = true,
                JobID = 243,
                DivisionID = 241,
                CS_Division = division
            };

            CS_Employee employee = new CS_Employee()
            {
                ID = 1,
                Active = true,
                Name = "Dcecilia",
                FirstName = "Test",
                DivisionID = 241
            };

            CS_Reserve reserve = new CS_Reserve()
            {
                Active = true,
                JobID = 243,
                Type = 2,
                CS_Employee = employee,
                DivisionID = 241
            };

            EntityCollection<CS_JobDivision> JobDivision = new EntityCollection<CS_JobDivision>();

            JobDivision.Add(jobdivision);

            CS_ScopeOfWork csScopeOfWork = new CS_ScopeOfWork()
            {
                Active = true,
                ScopeOfWork = "xxcxcxc",
                JobId = 243
            };

            EntityCollection<CS_Reserve> csReserves = new EntityCollection<CS_Reserve>();
//.........这里部分代码省略.........
开发者ID:danilocecilia,项目名称:HulcherProject,代码行数:101,代码来源:JobModelTest.cs

示例12: TestOrderByOperator

        public void TestOrderByOperator()
        {
            EntityCollection<TestAccountEntity> entities = new EntityCollection<TestAccountEntity>();
            entities.Add(new TestAccountEntity(100, 5));
            entities.Add(new TestAccountEntity(102, 8));
            entities.Add(new TestAccountEntity(103, 15));
            entities.Add(new TestAccountEntity(104, 2));

            IEnumerable<TestAccountEntity> result =
                    entities.OrderBy<long>(
                            delegate(TestAccountEntity entity)
                            {
                                return entity.Amount;
                            });

            Assert.IsNotNull(result);
            foreach (TestAccountEntity entity in result)
            {
                Assert.IsNotNull(entity);
                Console.WriteLine(entity);
            }
        }
开发者ID:abelperez,项目名称:csharp-commons,代码行数:22,代码来源:EntityCollectionTest.cs

示例13: TestTakeWhileOperator

        public void TestTakeWhileOperator()
        {
            EntityCollection<TestAccountEntity> entities = new EntityCollection<TestAccountEntity>();
            entities.Add(new TestAccountEntity(100, 5));
            entities.Add(new TestAccountEntity(102, 8));
            entities.Add(new TestAccountEntity(101, 15));
            entities.Add(new TestAccountEntity(101, 2));

            IEnumerable<TestAccountEntity> result =
                    entities.TakeWhile(
                            delegate(TestAccountEntity entity)
                            {
                                return (entity.Amount < 10) ? true : false;
                            });

            Assert.IsNotNull(result);
            foreach (TestAccountEntity entity in result)
            {
                Assert.IsNotNull(entity);
                Console.WriteLine(entity);
            }
        }
开发者ID:abelperez,项目名称:csharp-commons,代码行数:22,代码来源:EntityCollectionTest.cs

示例14: TestEntityCollectionOperatorOverloading

        public void TestEntityCollectionOperatorOverloading()
        {
            EntityCollection<TestEntity> collection = new EntityCollection<TestEntity>();
            TestEntity lead = new TestEntity();
            lead.Id = 1000;
            collection.Add(lead);

            EntityCollection<TestEntity> otherCollection = new EntityCollection<TestEntity>();
            TestEntity otherLead = new TestEntity();
            otherLead.Id = 2000;
            otherCollection.Add(otherLead);

            EntityCollection<TestEntity> finalCollection = collection + otherCollection;

            foreach (TestEntity tempLead in finalCollection)
            {
                Console.WriteLine("Lead: " + tempLead.Id);
            }
        }
开发者ID:abelperez,项目名称:csharp-commons,代码行数:19,代码来源:EntityCollectionTest.cs

示例15: TestGetCSV

        public void TestGetCSV()
        {
            TestEntity affiliate = new TestEntity();
            affiliate.Id = 1000;
            affiliate.Description = "desc 1";

            TestEntity affiliate0 = new TestEntity();
            affiliate0.Id = 1001;
            affiliate0.Description = "desc 2";

            TestEntity affiliate1 = new TestEntity();
            affiliate1.Id = 1002;
            affiliate1.Description = "desc 3";

            String[] stringArray = new string[] { "amin", "abel" };

            affiliate1.StringArray = stringArray;

            EntityCollection<TestEntity> collection = new EntityCollection<TestEntity>();
            collection.Add(affiliate);
            collection.Add(affiliate0);
            collection.Add(affiliate1);

            Console.Write(collection.GetCSV());
        }
开发者ID:abelperez,项目名称:csharp-commons,代码行数:25,代码来源:EntityCollectionTest.cs


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