本文整理汇总了C#中TestContext.Db方法的典型用法代码示例。如果您正苦于以下问题:C# TestContext.Db方法的具体用法?C# TestContext.Db怎么用?C# TestContext.Db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestContext
的用法示例。
在下文中一共展示了TestContext.Db方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Contract_ContractKomb2
public void Contract_ContractKomb2()
{
using (var ctx = new TestContext())
{
var tableMapping = ctx.Db<ContractKomb2>();
var columns = tableMapping.Properties;
Assert.AreEqual(26, columns.Length);
}
}
示例2: Contract_Contract
public void Contract_Contract()
{
using (var ctx = new TestContext())
{
var map = ctx.Db<Contract>();
var columns = map.Properties;
Assert.AreEqual(19, columns.Length);
map.Prop(x => x.Id)
.IsIdentity()
.IsFk(false)
.IsDiscriminator(false)
.IsRequired()
.HasColumnName("Id");
map.Prop(x => x.AvpContractNr)
.IsIdentity(false)
.IsFk(false)
.IsDiscriminator(false)
.IsRequired(false)
.HasColumnName("AvpContractNr")
.MaxLength(50);
}
}
示例3: Contract_ContractKomb1
public void Contract_ContractKomb1()
{
using (var ctx = new TestContext())
{
var tableMapping = ctx.Db<ContractKomb1>();
var columns = tableMapping.Properties;
Assert.AreEqual(24, columns.Length);
tableMapping.Prop(x => x.Base)
.HasColumnName("Base")
.HasPrecision(18)
.HasScale(4);
}
}
示例4: Contract_ContractBase
public void Contract_ContractBase()
{
using (var ctx = new TestContext())
{
var map = ctx.Db<ContractBase>();
var columns = map.Properties;
Assert.AreEqual(19, columns.Length);
Assert.AreEqual(1, map.Discriminators.Length);
}
}
示例5: Entity_ComplexType
public void Entity_ComplexType()
{
using (var ctx = new TestContext())
{
var map = ctx.Db<TestUser>();
map.Prop(x => x.Id)
.HasColumnName("Id")
.IsPk()
.IsFk(false)
.IsNavigationProperty(false);
map.Prop(x => x.FirstName)
.HasColumnName("Name")
.IsPk(false)
.IsFk(false)
.IsNavigationProperty(false)
.MaxLength(NvarcharMax);
map.Prop(x => x.LastName)
.HasColumnName("LastName")
.IsPk(false)
.IsFk(false)
.IsNavigationProperty(false)
.MaxLength(NvarcharMax);
map.Prop(x => x.Contact.PhoneNumber)
.HasColumnName("Contact_PhoneNumber")
.IsPk(false)
.IsFk(false)
.IsNavigationProperty(false)
.MaxLength(NvarcharMax);
map.Prop(x => x.Contact.BusinessAddress.StreetAddress)
.HasColumnName("Contact_BusinessAddress_StreetAddress")
.IsPk(false)
.IsFk(false)
.IsNavigationProperty(false)
.MaxLength(NvarcharMax);
map.Prop(x => x.Contact.BusinessAddress.County)
.HasColumnName("Contact_BusinessAddress_County")
.IsPk(false)
.IsFk(false)
.IsNavigationProperty(false)
.MaxLength(NvarcharMax);
map.Prop(x => x.Contact.BusinessAddress.Country)
.HasColumnName("Contact_BusinessAddress_Country")
.IsPk(false)
.IsFk(false)
.IsNavigationProperty(false)
.MaxLength(NvarcharMax);
map.Prop(x => x.Contact.BusinessAddress.City)
.HasColumnName("Contact_BusinessAddress_City")
.IsPk(false)
.IsFk(false)
.IsNavigationProperty(false)
.MaxLength(NvarcharMax);
map.Prop(x => x.Contact.BusinessAddress.PostalCode)
.HasColumnName("Contact_BusinessAddress_PostalCode")
.IsPk(false)
.IsFk(false)
.IsNavigationProperty(false)
.MaxLength(NvarcharMax);
map.Prop(x => x.Contact.ShippingAddress.StreetAddress)
.HasColumnName("Contact_ShippingAddress_StreetAddress")
.IsPk(false)
.IsFk(false)
.IsNavigationProperty(false)
.MaxLength(NvarcharMax);
map.Prop(x => x.Contact.ShippingAddress.Country)
.HasColumnName("Contact_ShippingAddress_Country")
.IsPk(false)
.IsFk(false)
.IsNavigationProperty(false)
.MaxLength(NvarcharMax);
map.Prop(x => x.Contact.ShippingAddress.County)
.HasColumnName("Contact_ShippingAddress_County")
.IsPk(false)
.IsFk(false)
.IsNavigationProperty(false)
.MaxLength(NvarcharMax);
map.Prop(x => x.Contact.ShippingAddress.City)
.HasColumnName("Contact_ShippingAddress_City")
.IsPk(false)
.IsFk(false)
.IsNavigationProperty(false)
.MaxLength(NvarcharMax);
map.Prop(x => x.Contact.ShippingAddress.PostalCode)
.HasColumnName("Contact_ShippingAddress_PostalCode")
.IsPk(false)
.IsFk(false)
//.........这里部分代码省略.........
示例6: Entity_Simple
public void Entity_Simple()
{
using (var ctx = new TestContext())
{
var map = ctx.Db<Page>();
Console.WriteLine("{0}:{1}", map.Type, map.TableName);
map.Prop(x => x.PageId)
.HasColumnName("PageId")
.IsPk()
.IsFk(false)
.IsIdentity()
.IsNavigationProperty(false);
map.Prop(x => x.Title)
.HasColumnName("Title")
.IsPk(false)
.IsFk(false)
.IsIdentity(false)
.IsRequired()
.IsNavigationProperty(false)
.MaxLength(255);
map.Prop(x => x.Content)
.HasColumnName("Content")
.IsPk(false)
.IsFk(false)
.IsIdentity(false)
.IsRequired(false)
.IsNavigationProperty(false)
.MaxLength(NvarcharMax);
map.Prop(x => x.ParentId)
.HasColumnName("ParentId")
.IsPk(false)
.IsFk()
.IsIdentity(false)
.IsRequired(false)
.IsNavigationProperty(false)
.NavigationPropertyName("Parent");
Assert.AreEqual(map.Prop(x => x.PageId), map.Prop(x => x.ParentId).FkTargetColumn);
map.Prop(x => x.Parent)
.HasColumnName("ParentId")
.IsPk(false)
.IsFk(false)
.IsIdentity(false)
.IsNavigationProperty()
.ForeignKeyPropertyName("ParentId")
.ForeignKey(map.Prop(x => x.ParentId));
map.Prop(x => x.CreatedAt)
.HasColumnName("CreatedAt")
.IsPk(false)
.IsFk(false)
.IsIdentity(false)
.IsRequired(true)
.IsNavigationProperty(false);
map.Prop(x => x.ModifiedAt)
.HasColumnName("ModifiedAt")
.IsPk(false)
.IsFk(false)
.IsRequired(false)
.IsIdentity(false)
.IsNavigationProperty(false);
}
}
示例7: Entity_ComplexType_WhereTwoComplexTypesAreAdjacent
public void Entity_ComplexType_WhereTwoComplexTypesAreAdjacent()
{
using (var ctx = new TestContext())
{
var map = ctx.Db<Company>();
map.Prop(x => x.FirstContact.BusinessAddress.StreetAddress)
.HasColumnName("FirstContact_BusinessAddress_StreetAddress");
map.Prop(x => x.FirstContact.ShippingAddress.StreetAddress)
.HasColumnName("FirstContact_ShippingAddress_StreetAddress");
map.Prop(x => x.BusinessAddress.StreetAddress)
.HasColumnName("BusinessAddress_StreetAddress");
map.Prop(x => x.ShippingAddress.StreetAddress)
.HasColumnName("ShippingAddress_StreetAddress");
}
}
示例8: Entity_ComplextType_WhereComplexTypeIsLastProperty
public void Entity_ComplextType_WhereComplexTypeIsLastProperty()
{
using (var ctx = new TestContext())
{
var map = ctx.Db<House>();
map.Prop(x => x.Name)
.HasColumnName("Name");
map.Prop(x => x.Address.Country)
.HasColumnName("Address_Country");
}
}