本文整理汇总了C#中MappingConfiguration.HasIdentity方法的典型用法代码示例。如果您正苦于以下问题:C# MappingConfiguration.HasIdentity方法的具体用法?C# MappingConfiguration.HasIdentity怎么用?C# MappingConfiguration.HasIdentity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MappingConfiguration
的用法示例。
在下文中一共展示了MappingConfiguration.HasIdentity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TeamUserMapping
private MappingConfiguration TeamUserMapping()
{
var mapping = new MappingConfiguration<TeamUser>();
mapping.MapType()
.ToTable("TeamUser");
mapping.HasIdentity(map => new
{
map.UserId,
map.TeamId,
});
mapping.HasAssociation(m => m.Team)
.WithOpposite(t => t.Members)
.IsManaged()
.IsDependent()
.ToColumn("TeamId");
mapping.HasAssociation(m => m.User)
.WithOpposite(t => t.Teams)
.IsManaged()
.IsDependent()
.ToColumn("UserId");
mapping.HasProperty(m => m.Status)
.HasColumnType("varchar")
.HasPrecision(25)
.WithConverter<EnumToStringConverter<TeamUserStatus>>();
mapping.HasProperty(m => m.Role)
.HasColumnType("varchar")
.HasPrecision(25)
.WithConverter<EnumToStringConverter<TeamUserRole>>();
return mapping;
}
示例2: UserThingMapping
private MappingConfiguration UserThingMapping()
{
var mapping = new MappingConfiguration<UserThing>();
mapping.MapType()
.ToTable("UserThing");
mapping.HasIdentity(map => new
{
map.AssignedToUserId,
map.ThingId
});
mapping.HasAssociation(m => m.Thing)
.IsManaged()
.IsDependent()
.ToColumn("ThingId");
mapping.HasAssociation(m => m.AssignedByUser)
.ToColumn("AssignedByUserId");
mapping.HasAssociation(m => m.AssignedToUser)
.WithOpposite(ut => ut.Things)
.ToColumn("AssignedToUserId");
return mapping;
}