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


C# MappingConfiguration类代码示例

本文整理汇总了C#中MappingConfiguration的典型用法代码示例。如果您正苦于以下问题:C# MappingConfiguration类的具体用法?C# MappingConfiguration怎么用?C# MappingConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: PrepareMapping

        protected override IList<MappingConfiguration> PrepareMapping()
        {
            List<MappingConfiguration> configurations = new List<MappingConfiguration>();

            MappingConfiguration<Report> reportConfiguration = new MappingConfiguration<Report>();

            reportConfiguration.MapType(x => new
            {
                ID = x.Id,
                Name = x.Name,
                Duration = x.Duration,
                Destination = x.Destination,
                ClientsCount = x.ClientsCount,
                TotalIncome = x.TotalIncome,
                TransportCompany = x.TransportCompany,
                TransportType = x.TransportType,
                GuideName = x.GuideName,
                ExpenseId = x.ExpenseId
            }).ToTable("Reports");

            reportConfiguration.HasProperty(p => p.Id).IsIdentity(KeyGenerator.Autoinc);

            configurations.Add(reportConfiguration);

            return configurations;
        }
开发者ID:DataBaseTeamSilver,项目名称:Travel-Agency,代码行数:26,代码来源:ReportsFluentSource.cs

示例2: TestFixtureSetUp

        protected override void TestFixtureSetUp()
        {
            base.TestFixtureSetUp();
            _session = Session;
            _session.CreateKeyspace(_uniqueKsName);
            _session.ChangeKeyspace(_uniqueKsName);

            // Create necessary tables
            MappingConfiguration config1 = new MappingConfiguration();
            config1.MapperFactory.PocoDataFactory.AddDefinitionDefault(typeof(EntityWithTimeUuid),
                () => LinqAttributeBasedTypeDefinition.DetermineAttributes(typeof(EntityWithTimeUuid)));
            _tableEntityWithTimeUuid = new Table<EntityWithTimeUuid>(_session, config1);
            _tableEntityWithTimeUuid.Create();

            MappingConfiguration config2 = new MappingConfiguration();
            config2.MapperFactory.PocoDataFactory.AddDefinitionDefault(typeof(EntityWithNullableTimeUuid),
                () => LinqAttributeBasedTypeDefinition.DetermineAttributes(typeof(EntityWithNullableTimeUuid)));
            _tableEntityWithNullableTimeUuid = new Table<EntityWithNullableTimeUuid>(_session, config2);
            _tableEntityWithNullableTimeUuid.Create();

            _expectedTimeUuidObjectList = EntityWithTimeUuid.GetDefaultObjectList();
            _expectedNullableTimeUuidObjectList = EntityWithNullableTimeUuid.GetDefaultObjectList();

            _dateBefore = DateTimeOffset.Parse("2014-2-1");
            _dateAfter = DateTimeOffset.Parse("2014-4-1");
        }
开发者ID:mtf30rob,项目名称:csharp-driver,代码行数:26,代码来源:MinTimeUuid.cs

示例3: GetRentalRateClassConfiguration

		public MappingConfiguration<RentalRate> GetRentalRateClassConfiguration()
		{
			MappingConfiguration<RentalRate> configuration = new MappingConfiguration<RentalRate>();
			configuration.MapType(x => new { }).WithConcurencyControl(OptimisticConcurrencyControlStrategy.Changed).ToTable("RentalRates");
		
			return configuration;
		}
开发者ID:Jarolim,项目名称:AllMyHomeworkForTelerikAcademy,代码行数:7,代码来源:EntitiesModelFluentMetadataSource.cs

示例4: ParseMappings

		private void ParseMappings(XPathNavigator navigator)
		{
			XPathNodeIterator xpni = navigator.Select(CfgXmlHelper.SessionFactoryMappingsExpression);
			while (xpni.MoveNext())
			{
				MappingConfiguration mc = new MappingConfiguration(xpni.Current);
				if (!mc.IsEmpty())
				{
					// Workaround add first an assembly&resource and then only the same assembly. 
					// the <mapping> of whole assembly is ignored (included only sigles resources)
					// The "ignore" log, is enough ?
					// Perhaps we can add some intelligence to remove single resource reference when a whole assembly is referenced
					//if (!mappings.Contains(mc))
					//{
					//  mappings.Add(mc);
					//}
					//else
					//{
					//  string logMessage = "Ignored mapping -> " + mc.ToString();
					//  if (log.IsDebugEnabled)
					//    log.Debug(logMessage);
					//  if (log.IsWarnEnabled)
					//    log.Warn(logMessage);
					//}

					// The control to prevent mappings duplication was removed since the engine do the right thing 
					// for this issue (simple is better)
					mappings.Add(mc);
				}
			}
		}
开发者ID:ray2006,项目名称:WCell,代码行数:31,代码来源:SessionFactoryConfiguration.cs

示例5: TestFixtureSetUp

        protected override void TestFixtureSetUp()
        {
            base.TestFixtureSetUp();
            _session = Session;
            _session.CreateKeyspace(_uniqueKsName);
            _session.ChangeKeyspace(_uniqueKsName);

            // Create necessary tables
            MappingConfiguration config1 = new MappingConfiguration();
            config1.MapperFactory.PocoDataFactory.AddDefinitionDefault(typeof (EntityWithTimeUuid),
                () => LinqAttributeBasedTypeDefinition.DetermineAttributes(typeof (EntityWithTimeUuid)));
            _tableEntityWithTimeUuid = new Table<EntityWithTimeUuid>(_session, config1);
            _tableEntityWithTimeUuid.Create();

            MappingConfiguration config2 = new MappingConfiguration();
            config2.MapperFactory.PocoDataFactory.AddDefinitionDefault(typeof (EntityWithNullableTimeUuid),
                () => LinqAttributeBasedTypeDefinition.DetermineAttributes(typeof (EntityWithNullableTimeUuid)));
            _tableEntityWithNullableTimeUuid = new Table<EntityWithNullableTimeUuid>(_session, config2);
            _tableEntityWithNullableTimeUuid.Create();

            _expectedTimeUuidObjectList = EntityWithTimeUuid.GetDefaultObjectList();
            for (int i=0; i<_expectedTimeUuidObjectList.Count; i++)
            {
                _expectedTimeUuidObjectList[i].StringType = i.ToString();
            }
        }
开发者ID:mtf30rob,项目名称:csharp-driver,代码行数:26,代码来源:Token.cs

示例6: MapUrlData

 /// <summary>
 /// Maps the ProjectItemUrlData class
 /// </summary>
 /// <param name="mappings">The LocatoinItemUrlData class mappings.</param>
 private void MapUrlData(IList<MappingConfiguration> mappings)
 {
     // map the Url data type
     var urlDataMapping = new MappingConfiguration<ProjectItemUrlData>();
     urlDataMapping.MapType(p => new { }).Inheritance(InheritanceStrategy.Flat).ToTable("sf_url_data");
     mappings.Add(urlDataMapping);
 }
开发者ID:eulalie367,项目名称:littleapps,代码行数:11,代码来源:FluentMapping.cs

示例7: TeamMapping

        private MappingConfiguration TeamMapping()
        {
            var mapping = new MappingConfiguration<Team>();

            mapping.MapType()
                   .ToTable("Team");

            mapping.HasProperty(m => m.Id)
                   .IsIdentity(KeyGenerator.Autoinc);

            mapping.HasProperty(m => m.IsOpen)
                   .HasColumnType("bit");

            mapping.HasAssociation(m => m.Owner)
                   .IsManaged()
                   .ToColumn("OwnerId");

            mapping.HasAssociation(m => m.Things)
                   .IsManaged()
                   .ToColumn("TeamId");

            mapping.HasAssociation(m => m.Members)
                   .WithOpposite(t => t.Team)
                   .IsManaged()
                   .IsDependent()
                   .ToColumn("TeamId");

            return mapping;
        }
开发者ID:jessemlay,项目名称:TeamThing,代码行数:29,代码来源:TeamThingMetadataSource.cs

示例8: CreateQuestionMapping

        private MappingConfiguration<Question> CreateQuestionMapping()
        {
            MappingConfiguration<Question> questionMapping = new MappingConfiguration<Question>();
            questionMapping.MapType(question => new
            {
                QuestionId = question.Id,
                QueryText = question.QueryText,
                PostedById = question.PostedById
            })
            .ToTable("Questions");
            questionMapping.HasProperty(q => q.Id).IsIdentity();
            questionMapping.HasAssociation(q => q.PostedBy)
                .WithOpposite(u => u.CreatedQuestions)
                .HasConstraint((q, u) => q.PostedById == u.Id);
            questionMapping.HasAssociation(q => q.UsersThatVoted)
                .WithOpposite(u => u.VotedOnQuestions)
                .IsManaged()
                .MapJoinTable("QuestionsUsers", (q, u) => new 
                    {
                        QuestionGuid = q.Id,
                        UserGuid = u.Id
                    });
            questionMapping.HasAssociation(q => q.Answers)
                .WithOpposite(a => a.Question)
                .HasConstraint((q, a) => q.Id == a.QuestionId)
                .IsManaged();

            return questionMapping;
        }
开发者ID:BPalagachev,项目名称:PollSystem,代码行数:29,代码来源:IdentityModelMetadataSource.cs

示例9: PrepareDataAccessCountryPropertyConfigurations

 public void PrepareDataAccessCountryPropertyConfigurations(MappingConfiguration<DataAccessCountry> configuration)
 {
     configuration.HasProperty(x => x.Id)
                  .IsIdentity(KeyGenerator.Autoinc)
                  .HasFieldName("id")
                  .WithDataAccessKind(DataAccessKind.ReadWrite)
                  .ToColumn("Id")
                  .IsNotNullable()
                  .HasColumnType("integer")
                  .HasPrecision(0)
                  .HasScale(0);
     configuration.HasProperty(x => x.Name)
                  .HasFieldName("name")
                  .WithDataAccessKind(DataAccessKind.ReadWrite)
                  .ToColumn("Name")
                  .IsNullable()
                  .HasColumnType("longtext")
                  .HasLength(0);
     configuration.HasProperty(x => x.Region)
                  .HasFieldName("region")
                  .WithDataAccessKind(DataAccessKind.ReadWrite)
                  .ToColumn("Region")
                  .IsNotNullable()
                  .HasColumnType("integer")
                  .HasPrecision(0)
                  .HasScale(0);
 }
开发者ID:kalinalazarova1,项目名称:TeamGiant-DatabaseProject,代码行数:27,代码来源:VehicleVendorCustomMetadataSource.cs

示例10: PrepareTeamPropertyConfigurations

		public void PrepareTeamPropertyConfigurations(MappingConfiguration<Team> configuration)
		{
			configuration.HasProperty(x => x.TeamId).IsIdentity().HasFieldName("_teamId").WithDataAccessKind(DataAccessKind.ReadWrite);
			configuration.HasProperty(x => x.TeamMembers).HasFieldName("_teamMembers").WithDataAccessKind(DataAccessKind.ReadWrite);
			configuration.HasProperty(x => x.TeamName).HasFieldName("_teamName").WithDataAccessKind(DataAccessKind.ReadWrite);
			configuration.HasProperty(x => x.IsEnabled).HasFieldName("_isEnabled").WithDataAccessKind(DataAccessKind.ReadWrite);
		}
开发者ID:Go9Rhodes,项目名称:TeamThing,代码行数:7,代码来源:TeamThingModelFluentMetadataSource.cs

示例11: GetTeamMemberClassConfiguration

		public MappingConfiguration<TeamMember> GetTeamMemberClassConfiguration()
		{
			MappingConfiguration<TeamMember> configuration = new MappingConfiguration<TeamMember>();
			configuration.MapType().WithDataAccessKind(DataAccessKind.ReadWrite);
		
			return configuration;
		}
开发者ID:Go9Rhodes,项目名称:TeamThing,代码行数:7,代码来源:TeamThingModelFluentMetadataSource.cs

示例12: PrepareMapping

        protected override IList<MappingConfiguration> PrepareMapping()
        {
            List<MappingConfiguration> configurations = new List<MappingConfiguration>();

            var saleMapping = new MappingConfiguration<Sale>();
           saleMapping.MapType(sale => new
            {
                ID = sale.Id,
                Dish = sale.Dish,
                Quantity = sale.Quantity,
                Month = sale.Month,
                Year = sale.Year
            }).ToTable("Sale");
            saleMapping.HasProperty(s => s.Id).IsIdentity();

            configurations.Add(saleMapping);

            var dishReportMapping = new MappingConfiguration<DishReport>();
            dishReportMapping.MapType(report => new
            {
                Month = report.Month,
                DeliveredPrice = report.DeliveredPrice,
                SoldPrice = report.SoldPrice,
                Code = report.Code,
            }).ToTable("DishReport");
            saleMapping.HasProperty(s => s.Id).IsIdentity();

            configurations.Add(dishReportMapping);

            return configurations;
        }
开发者ID:ScreeM92,项目名称:Software-University,代码行数:31,代码来源:CentaurFactoryModelMetadataSource.cs

示例13: CqlClient_Timestamp

        public void CqlClient_Timestamp()
        {
            var config = new MappingConfiguration()
                .Define(new Map<Song>().PartitionKey(s => s.Id).TableName("song_insert"));

            //Use linq to create the table
            var table = new Table<Song>(_session, config);
            table.CreateIfNotExists();
            var mapper = new Mapper(_session, config);
            var song = new Song
            {
                Id = Guid.NewGuid(),
                Artist = "The Who",
                Title = "Substitute",
                ReleaseDate = DateTimeOffset.UtcNow
            };
            //Set timestamp to 1 day ago
            var timestamp = DateTimeOffset.Now.Subtract(TimeSpan.FromDays(1));
            mapper.Insert(song, true, CqlQueryOptions.New().SetTimestamp(timestamp));

            //query for timestamp in a column of the record
            var cqlLowerCasePartitionKey = "SELECT WRITETIME (Artist) AS timestamp FROM " + table.Name + " WHERE Id = " + song.Id + ";";
            var rows = _session.Execute(cqlLowerCasePartitionKey).GetRows().ToList();
            Assert.AreEqual(1, rows.Count);

            var creationTimestamp = rows[0].GetValue<long>("timestamp");
            Assert.NotNull(creationTimestamp);
            //Timestamp retrieved is in macroseconds. Converting it to milliseconds
            Assert.AreEqual(TypeSerializer.SinceUnixEpoch(timestamp).Ticks / 10, rows[0].GetValue<object>("timestamp"));
        }
开发者ID:yar1k0v,项目名称:csharp-driver,代码行数:30,代码来源:InsertTests.cs

示例14: PreparePositionPropertyConfigurations

		public void PreparePositionPropertyConfigurations(MappingConfiguration<Position> configuration) {
			configuration.HasProperty(x => x.Id).IsIdentity(KeyGenerator.Autoinc);
			configuration.HasProperty(x => x.HeaderId);
			configuration.HasProperty(x => x.Description);
			configuration.HasProperty(x => x.SequenceNumber);
			configuration.HasProperty(x => x.DateCreated);
			configuration.HasProperty(x => x.DateModified);
		}
开发者ID:bdongus,项目名称:UMLExtensions,代码行数:8,代码来源:MetadataSource.generated.cs

示例15: PrepareHeaderPropertyConfigurations

		public void PrepareHeaderPropertyConfigurations(MappingConfiguration<Header> configuration) {
			configuration.HasProperty(x => x.Id);
			configuration.HasProperty(x => x.Title);
			configuration.HasProperty(x => x.IsChecked);
			configuration.HasProperty(x => x.Status);
			configuration.HasProperty(x => x.DateCreated);
			configuration.HasProperty(x => x.DateModified);
		}
开发者ID:bdongus,项目名称:UMLExtensions,代码行数:8,代码来源:MetadataSource.generated.cs


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