本文整理汇总了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;
}
示例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");
}
示例3: GetRentalRateClassConfiguration
public MappingConfiguration<RentalRate> GetRentalRateClassConfiguration()
{
MappingConfiguration<RentalRate> configuration = new MappingConfiguration<RentalRate>();
configuration.MapType(x => new { }).WithConcurencyControl(OptimisticConcurrencyControlStrategy.Changed).ToTable("RentalRates");
return configuration;
}
示例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);
}
}
}
示例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();
}
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例11: GetTeamMemberClassConfiguration
public MappingConfiguration<TeamMember> GetTeamMemberClassConfiguration()
{
MappingConfiguration<TeamMember> configuration = new MappingConfiguration<TeamMember>();
configuration.MapType().WithDataAccessKind(DataAccessKind.ReadWrite);
return configuration;
}
示例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;
}
示例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"));
}
示例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);
}
示例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);
}