本文整理汇总了C#中IPropertyMap.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# IPropertyMap.Clone方法的具体用法?C# IPropertyMap.Clone怎么用?C# IPropertyMap.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPropertyMap
的用法示例。
在下文中一共展示了IPropertyMap.Clone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTableForProperty
protected virtual void CreateTableForProperty(IPropertyMap propertyMap, IDomainMap targetDomainMap, bool generateMappings)
{
IClassMap classMap = propertyMap.ClassMap;
ITableMap tableMap = null;
ISourceMap sourceMap = null;
ISourceMap addToSourceMap = null;
IClassMap classMapClone = null;
IPropertyMap propertyMapClone = null;
string name = "";
sourceMap = classMap.GetSourceMap();
if (sourceMap == null)
{
sourceMap = classMap.DomainMap.GetSourceMap();
if (sourceMap == null)
{
throw new Exception("No default data source specified for domain model! Can't add table for class!");
}
}
addToSourceMap = targetDomainMap.GetSourceMap(sourceMap.Name);
if (addToSourceMap == null)
{
addToSourceMap = (ISourceMap) sourceMap.Clone();
addToSourceMap.DomainMap = targetDomainMap;
}
if (propertyMap.Table.Length > 0)
{
name = propertyMap.Table;
}
else
{
name = GetTableNameForProperty(propertyMap);
}
tableMap = addToSourceMap.GetTableMap(name);
if (tableMap == null)
{
tableMap = new TableMap();
tableMap.Name = name;
tableMap.SourceMap = addToSourceMap;
}
if (generateMappings & propertyMap.Table.Length < 1)
{
classMapClone = targetDomainMap.GetClassMap(classMap.Name);
if (classMapClone == null)
{
classMapClone = (IClassMap) classMap.Clone();
classMapClone.Table = tableMap.Name;
if (!(addToSourceMap.Name == targetDomainMap.Source))
{
classMapClone.Source = addToSourceMap.Name;
}
classMapClone.DomainMap = targetDomainMap;
}
propertyMapClone = classMapClone.GetPropertyMap(propertyMap.Name);
if (propertyMapClone == null)
{
propertyMapClone = (IPropertyMap) propertyMap.Clone();
propertyMapClone.ClassMap = classMapClone;
}
propertyMapClone.Table = tableMap.Name;
if (!(addToSourceMap.Name == classMapClone.Source))
{
if (!(addToSourceMap.Name == targetDomainMap.Source))
{
propertyMapClone.Source = addToSourceMap.Name;
}
}
}
}
示例2: CreateColumnForProperty
protected virtual void CreateColumnForProperty(IPropertyMap propertyMap, IDomainMap targetDomainMap, bool generateMappings, IClassMap ownerClassMap)
{
IClassMap classMap = propertyMap.ClassMap;
ITableMap tableMap = null;
ISourceMap sourceMap = null;
ISourceMap addToSourceMap = null;
IClassMap classMapClone = null;
IPropertyMap propertyMapClone = null;
IColumnMap columnMap = null;
string classTableName = "";
string name = "";
string tableName = "";
bool allowNulls = false;
IClassMap refClassMap = null;
string forTableName = "";
string forColumnName = "";
int cnt = 0;
bool found = false;
string primColName = "";
string ownerClassTableName = "";
string foreignKeyName = "";
sourceMap = classMap.GetSourceMap();
if (sourceMap == null)
{
sourceMap = classMap.DomainMap.GetSourceMap();
if (sourceMap == null)
{
throw new Exception("No default data source specified for domain model! Can't add table for class!");
}
}
addToSourceMap = targetDomainMap.GetSourceMap(sourceMap.Name);
if (addToSourceMap == null)
{
addToSourceMap = (ISourceMap) sourceMap.Clone();
addToSourceMap.DomainMap = targetDomainMap;
}
if (propertyMap.ClassMap.Table.Length > 0)
{
classTableName = propertyMap.ClassMap.Table;
}
else
{
classTableName = GetTableNameForClass(propertyMap.ClassMap);
}
if (propertyMap.Table.Length > 0)
{
tableName = propertyMap.Table;
}
else if (propertyMap.IsCollection)
{
tableName = GetTableNameForProperty(propertyMap);
}
else
{
if (IsOutbrokenByInheritance(propertyMap, ownerClassMap))
{
ownerClassTableName = GetTableNameForClass(ownerClassMap, true);
tableName = ownerClassTableName;
}
else
{
tableName = classTableName;
}
}
tableMap = addToSourceMap.GetTableMap(tableName);
if (tableMap == null)
{
tableMap = new TableMap();
tableMap.Name = tableName;
tableMap.SourceMap = addToSourceMap;
}
if (propertyMap.Column.Length > 0)
{
name = propertyMap.Column;
}
else
{
name = GetColumnNameForProperty(propertyMap);
}
columnMap = tableMap.GetColumnMap(name);
if (columnMap == null)
{
columnMap = new ColumnMap();
columnMap.Name = name;
columnMap.TableMap = tableMap;
}
columnMap.DataType = GetColumnTypeForProperty(propertyMap);
columnMap.Length = GetColumnLengthForProperty(propertyMap);
columnMap.Precision = GetColumnPrecisionForProperty(propertyMap);
columnMap.Scale = GetColumnScaleForProperty(propertyMap);
allowNulls = propertyMap.IsNullable;
if (propertyMap.IsIdentity)
{
allowNulls = false;
}
columnMap.AllowNulls = allowNulls;
if (propertyMap.IsIdentity)
{
columnMap.IsPrimaryKey = true;
columnMap.AllowNulls = false;
//.........这里部分代码省略.........
示例3: CreateIDColumnForProperty
protected virtual void CreateIDColumnForProperty(IPropertyMap propertyMap, IDomainMap targetDomainMap, bool generateMappings, IClassMap ownerClassMap)
{
IClassMap classMap = propertyMap.ClassMap;
ITableMap tableMap = null;
ISourceMap sourceMap = null;
ISourceMap addToSourceMap = null;
IClassMap classMapClone = null;
IPropertyMap propertyMapClone = null;
IColumnMap columnMap = null;
string classTableName = "";
string ownerClassTableName = "";
string name = "";
string forColName = "";
string tableName = "";
string foreignKeyName = "";
bool isClassTableOrConcrete = false;
sourceMap = classMap.GetSourceMap();
if (sourceMap == null)
{
sourceMap = classMap.DomainMap.GetSourceMap();
if (sourceMap == null)
{
throw new Exception("No default data source specified for domain model! Can't add table for class!");
}
}
addToSourceMap = targetDomainMap.GetSourceMap(sourceMap.Name);
if (addToSourceMap == null)
{
addToSourceMap = (ISourceMap) sourceMap.Clone();
addToSourceMap.DomainMap = targetDomainMap;
}
if (propertyMap.ClassMap.Table.Length > 0)
{
classTableName = propertyMap.ClassMap.Table;
}
else
{
classTableName = GetTableNameForClass(propertyMap.ClassMap);
}
if (propertyMap.Table.Length > 0)
{
tableName = propertyMap.Table;
}
else if (propertyMap.IsCollection)
{
tableName = GetTableNameForProperty(propertyMap);
}
else
{
if (IsOutbrokenByInheritance(propertyMap, ownerClassMap))
{
isClassTableOrConcrete = true;
ownerClassTableName = GetTableNameForClass(ownerClassMap, true);
tableName = ownerClassTableName;
}
else
{
tableName = classTableName;
}
}
tableMap = addToSourceMap.GetTableMap(tableName);
if (tableMap == null)
{
tableMap = new TableMap();
tableMap.Name = tableName;
tableMap.SourceMap = addToSourceMap;
}
foreignKeyName = "FK_" + tableMap.Name;
foreach (IPropertyMap idPropertyMap in propertyMap.ClassMap.GetIdentityPropertyMaps())
{
if (idPropertyMap.Column.Length > 0)
{
forColName = idPropertyMap.Column;
}
else
{
forColName = GetColumnNameForProperty(idPropertyMap);
}
foreignKeyName += "_" + forColName;
}
if (!(classMap.InheritanceType == InheritanceType.None))
{
if (classMap.TypeColumn.Length > 0)
{
foreignKeyName += "_" + classMap.TypeColumn;
}
else
{
foreignKeyName += "_" + GetTypeColumnNameForClass(classMap);
}
}
foreach (IPropertyMap idPropertyMap in propertyMap.ClassMap.GetIdentityPropertyMaps())
{
if (idPropertyMap.Column.Length > 0)
{
forColName = idPropertyMap.Column;
}
else
{
forColName = GetColumnNameForProperty(idPropertyMap);
//.........这里部分代码省略.........