本文整理汇总了C#中FluentNHibernate.MappingModel.ClassBased.ClassMappingBase类的典型用法代码示例。如果您正苦于以下问题:C# ClassMappingBase类的具体用法?C# ClassMappingBase怎么用?C# ClassMappingBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClassMappingBase类属于FluentNHibernate.MappingModel.ClassBased命名空间,在下文中一共展示了ClassMappingBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Map
public void Map(ClassMappingBase classMap, Member member)
{
if (!(classMap is ClassMapping)) return;
var version = new VersionMapping
{
ContainingEntityType = classMap.Type,
};
version.Set(x => x.Name, Layer.Defaults, member.Name);
version.Set(x => x.Type, Layer.Defaults, GetDefaultType(member));
var columnMapping = new ColumnMapping();
columnMapping.Set(x => x.Name, Layer.Defaults, member.Name);
version.AddColumn(Layer.Defaults, columnMapping);
SetDefaultAccess(member, version);
if (IsSqlTimestamp(member))
{
version.Columns.Each(column =>
{
column.Set(x => x.SqlType, Layer.Defaults, "timestamp");
column.Set(x => x.NotNull, Layer.Defaults, true);
});
version.Set(x => x.UnsavedValue, Layer.Defaults, null);
}
((ClassMapping)classMap).Set(x => x.Version, Layer.Defaults, version);
}
示例2: MapEverythingInClass
public virtual void MapEverythingInClass(ClassMappingBase mapping, Type entityType, IList<string> mappedProperties)
{
foreach (var property in entityType.GetProperties())
{
TryToMapProperty(mapping, property.ToMember(), mappedProperties);
}
}
示例3: Map
public void Map(ClassMappingBase classMap, Member member)
{
if (!(classMap is ClassMapping)) return;
var version = new VersionMapping
{
Name = member.Name,
ContainingEntityType = classMap.Type,
};
version.SetDefaultValue("Type", GetDefaultType(member));
version.AddDefaultColumn(new ColumnMapping { Name = member.Name });
if (member.IsProperty && !member.CanWrite)
version.Access = cfg.GetAccessStrategyForReadOnlyProperty(member).ToString();
if (IsSqlTimestamp(member))
{
version.Columns.Each(x =>
{
x.SqlType = "timestamp";
x.NotNull = true;
});
version.UnsavedValue = null;
}
((ClassMapping)classMap).Version = version;
}
示例4: Map
public void Map(ClassMappingBase classMap, PropertyInfo property)
{
if (property.DeclaringType != classMap.Type || !(classMap is ClassMapping))
return;
var version = new VersionMapping
{
Name = property.Name,
};
version.SetDefaultValue("Type", GetDefaultType(property));
version.AddDefaultColumn(new ColumnMapping { Name = property.Name });
if (IsSqlTimestamp(property))
{
version.Columns.Each(x =>
{
x.SqlType = "timestamp";
x.NotNull = true;
});
version.UnsavedValue = null;
}
((ClassMapping)classMap).Version = version;
}
示例5: MapInheritanceTree
private void MapInheritanceTree(Type classType, ClassMappingBase mapping, IList<Member> mappedMembers)
{
var discriminatorSet = HasDiscriminator(mapping);
var isDiscriminated = cfg.IsDiscriminated(classType) || discriminatorSet;
var mappingTypesWithLogicalParents = GetMappingTypesWithLogicalParents();
foreach (var inheritedClass in mappingTypesWithLogicalParents
.Where(x => x.Value != null && x.Value.Type == classType)
.Select(x => x.Key))
{
var tempMapping = mapping as ClassMapping;
var tempIsNull = tempMapping == null;
if (isDiscriminated && !discriminatorSet && !tempIsNull)
{
var discriminatorColumn = cfg.GetDiscriminatorColumn(classType);
var discriminator = new DiscriminatorMapping
{
ContainingEntityType = classType,
Type = new TypeReference(typeof(string))
};
discriminator.AddDefaultColumn(new ColumnMapping { Name = discriminatorColumn });
tempMapping.Discriminator = discriminator;
discriminatorSet = true;
}
SubclassMapping subclassMapping;
if(!tempIsNull && tempMapping.IsUnionSubclass)
{
subclassMapping = new SubclassMapping(SubclassType.UnionSubclass)
{
Type = inheritedClass.Type
};
}
else if(!isDiscriminated)
{
subclassMapping = new SubclassMapping(SubclassType.JoinedSubclass)
{
Type = inheritedClass.Type
};
subclassMapping.Key = new KeyMapping();
subclassMapping.Key.AddDefaultColumn(new ColumnMapping { Name = mapping.Type.Name + "_id" });
}
else
subclassMapping = new SubclassMapping(SubclassType.Subclass)
{
Type = inheritedClass.Type
};
// track separate set of properties for each sub-tree within inheritance hierarchy
var subclassMembers = new List<Member>(mappedMembers);
MapSubclass(subclassMembers, subclassMapping, inheritedClass);
mapping.AddSubclass(subclassMapping);
MergeMap(inheritedClass.Type, subclassMapping, subclassMembers);
}
}
示例6: ProcessClassBase
protected override void ProcessClassBase(ClassMappingBase classMapping)
{
if (!classMapping.IsNameSpecified)
{
if (classMapping.Type == null)
throw new ConventionException("Cannot apply the naming convention. No type specified.", classMapping);
classMapping.Name = DetermineNameFromType(classMapping.Type);
}
}
示例7: Map
public void Map(ClassMappingBase classMap, Member member)
{
// don't map the component here, mark it as a reference which'll
// allow us to integrate with ComponentMap or automap at a later
// stage
var mapping = new ReferenceComponentMapping(ComponentType.Component, member, member.PropertyType, classMap.Type, cfg.GetComponentColumnPrefix(member));
classMap.AddComponent(mapping);
}
示例8: Map
public void Map(ClassMappingBase classMap, Member member)
{
if (!(classMap is ClassMapping)) {
return;
}
var identity = ((ClassMapping) classMap).Id;
if (identity == null) {
var idMapping = new IdMapping {ContainingEntityType = classMap.Type};
var columnMapping = new ColumnMapping();
columnMapping.Set(x => x.Name, Layer.Defaults, member.Name);
idMapping.AddColumn(Layer.Defaults, columnMapping);
idMapping.Set(x => x.Name, Layer.Defaults, member.Name);
idMapping.Set(x => x.Type, Layer.Defaults, new TypeReference(member.PropertyType));
idMapping.Member = member;
idMapping.Set(x => x.Generator, Layer.Defaults, GetDefaultGenerator(member));
SetDefaultAccess(member, idMapping);
identity = idMapping;
}
else {
if (identity is IdMapping) {
var idMapping = identity as IdMapping;
var compositeId = new CompositeIdMapping {ContainingEntityType = classMap.Type};
var idKeyPropertyMapping = GetKeyPropertyMapping(classMap.Type, idMapping.Name,
idMapping.Type.GetUnderlyingSystemType());
var keyPropertyMapping = GetKeyPropertyMapping(classMap.Type, member.Name,
member.PropertyType);
compositeId.AddKey(idKeyPropertyMapping);
compositeId.AddKey(keyPropertyMapping);
identity = compositeId;
}
else if (identity is CompositeIdMapping) {
var compositeId = identity as CompositeIdMapping;
var keyPropertyMapping = GetKeyPropertyMapping(classMap.Type, member.Name,
member.PropertyType);
compositeId.AddKey(keyPropertyMapping);
identity = compositeId;
}
else {
throw new NotImplementedException(
string.Format("Mayank: Fluent nhibernate not exended to support type '{0}'",
identity.GetType().Name));
}
}
((ClassMapping) classMap).Set(x => x.Id, Layer.Defaults, identity);
}
示例9: SetRelationship
private void SetRelationship(Member property, ClassMappingBase classMap, ICollectionMapping mapping)
{
var relationship = new OneToManyMapping
{
Class = new TypeReference(property.PropertyType.GetGenericArguments()[0]),
ContainingEntityType = classMap.Type
};
mapping.SetDefaultValue(x => x.Relationship, relationship);
}
示例10: SetKey
private void SetKey(Member property, ClassMappingBase classMap, ICollectionMapping mapping)
{
var columnName = property.DeclaringType.Name + "_id";
var key = new KeyMapping();
key.ContainingEntityType = classMap.Type;
key.AddDefaultColumn(new ColumnMapping { Name = columnName });
mapping.SetDefaultValue(x => x.Key, key);
}
示例11: Map
public void Map(ClassMappingBase classMap, Member property)
{
var inverseProperty = GetInverseProperty(property);
var parentSide = expressions.GetParentSideForManyToMany(property.DeclaringType, inverseProperty.DeclaringType);
var mapping = GetCollection(property);
ConfigureModel(property, mapping, classMap, parentSide);
classMap.AddCollection(mapping);
}
示例12: Map
public void Map(ClassMappingBase classMap, Member member)
{
if (member.DeclaringType != classMap.Type)
return;
if (simpleTypeCollectionStepStep.ShouldMap(member))
simpleTypeCollectionStepStep.Map(classMap, member);
else if (collectionStep.ShouldMap(member))
collectionStep.Map(classMap, member);
}
示例13: Map
public void Map(ClassMappingBase classMap, Member member)
{
var inverseProperty = GetInverseProperty(member);
var parentSide = cfg.GetParentSideForManyToMany(member.DeclaringType, inverseProperty.DeclaringType);
var mapping = GetCollection(member);
ConfigureModel(member, mapping, classMap, parentSide);
classMap.AddCollection(mapping);
}
示例14: Map
public void Map(ClassMappingBase classMap, Member property)
{
if (property.DeclaringType != classMap.Type)
return;
if (simpleTypeCollectionStep.MapsProperty(property))
simpleTypeCollectionStep.Map(classMap, property);
else if (entityCollectionStep.MapsProperty(property))
entityCollectionStep.Map(classMap, property);
}
示例15: SetRelationship
static void SetRelationship(Member property, ClassMappingBase classMap, CollectionMapping mapping)
{
var relationship = new OneToManyMapping
{
ContainingEntityType = classMap.Type
};
relationship.Set(x => x.Class, Layer.Defaults, new TypeReference(property.PropertyType.GetGenericArguments()[0]));
mapping.Set(x => x.Relationship, Layer.Defaults, relationship);
}