本文整理汇总了C#中IMapper.MapMemberToColumn方法的典型用法代码示例。如果您正苦于以下问题:C# IMapper.MapMemberToColumn方法的具体用法?C# IMapper.MapMemberToColumn怎么用?C# IMapper.MapMemberToColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMapper
的用法示例。
在下文中一共展示了IMapper.MapMemberToColumn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PocoData
public PocoData(Type t, IMapper mapper, Cache<string, Type> aliasToTypeCache)
: this()
{
aliasToType = aliasToTypeCache;
type = t;
Mapper = mapper;
TableInfo = TableInfo.FromPoco(t);
// Call column mapper
if (Mapper != null)
Mapper.GetTableInfo(t, TableInfo);
var alias = CreateAlias(type.Name, type);
TableInfo.AutoAlias = alias;
var index = 0;
// Work out bound properties
Columns = new Dictionary<string, PocoColumn>(StringComparer.OrdinalIgnoreCase);
foreach (var mi in ReflectionUtils.GetFieldsAndPropertiesForClasses(t))
{
ColumnInfo ci = ColumnInfo.FromMemberInfo(mi);
if (ci.IgnoreColumn)
continue;
var pc = new PocoColumn();
pc.TableInfo = TableInfo;
pc.MemberInfo = mi;
pc.ColumnName = ci.ColumnName;
pc.ResultColumn = ci.ResultColumn;
pc.ForceToUtc = ci.ForceToUtc;
pc.ComputedColumn = ci.ComputedColumn;
pc.ColumnType = ci.ColumnType;
pc.ColumnAlias = ci.ColumnAlias;
pc.VersionColumn = ci.VersionColumn;
pc.VersionColumnType = ci.VersionColumnType;
if (Mapper != null && !Mapper.MapMemberToColumn(mi, ref pc.ColumnName, ref pc.ResultColumn))
continue;
pc.AutoAlias = alias + "_" + index++;
// Store it
if (!Columns.ContainsKey(pc.ColumnName))
Columns.Add(pc.ColumnName, pc);
}
// Build column list for automatic select
QueryColumns = Columns.Where(c => !c.Value.ResultColumn).ToArray();
}
示例2: FluentMappingsPocoData
public FluentMappingsPocoData(Type t, TypeDefinition typeConfig, IMapper mapper)
{
Mapper = mapper;
type = t;
TableInfo = new TableInfo();
// Get the table name
var a = typeConfig.TableName ?? "";
TableInfo.TableName = a.Length == 0 ? t.Name : a;
// Get the primary key
a = typeConfig.PrimaryKey ?? "";
TableInfo.PrimaryKey = a.Length == 0 ? "ID" : a;
a = typeConfig.SequenceName ?? "";
TableInfo.SequenceName = a.Length == 0 ? null : a;
TableInfo.AutoIncrement = typeConfig.AutoIncrement ?? true;
// Set autoincrement false if primary key has multiple columns
TableInfo.AutoIncrement = TableInfo.AutoIncrement ? !TableInfo.PrimaryKey.Contains(',') : TableInfo.AutoIncrement;
// Call column mapper
if (mapper != null)
mapper.GetTableInfo(t, TableInfo);
// Work out bound properties
bool explicitColumns = typeConfig.ExplicitColumns ?? false;
Columns = new Dictionary<string, PocoColumn>(StringComparer.OrdinalIgnoreCase);
foreach (var mi in ReflectionUtils.GetFieldsAndPropertiesForClasses(t))
{
// Work out if properties is to be included
var isColumnDefined = typeConfig.ColumnConfiguration.ContainsKey(mi.Name);
if (explicitColumns && !isColumnDefined) continue;
if (isColumnDefined && (typeConfig.ColumnConfiguration[mi.Name].IgnoreColumn.HasValue && typeConfig.ColumnConfiguration[mi.Name].IgnoreColumn.Value))
continue;
var pc = new PocoColumn();
pc.MemberInfo = mi;
// Work out the DB column name
if (isColumnDefined)
{
var colattr = typeConfig.ColumnConfiguration[mi.Name];
pc.ColumnName = colattr.DbColumnName;
if (colattr.ResultColumn.HasValue && colattr.ResultColumn.Value)
pc.ResultColumn = true;
else if (colattr.VersionColumn.HasValue && colattr.VersionColumn.Value)
pc.VersionColumn = true;
if (colattr.ForceUtc.HasValue && colattr.ForceUtc.Value)
pc.ForceToUtc = true;
if (TableInfo.PrimaryKey.Split(',').Contains(mi.Name))
TableInfo.PrimaryKey = (pc.ColumnName ?? mi.Name) + ",";
pc.ColumnType = colattr.DbColumnType;
}
if (pc.ColumnName == null)
{
pc.ColumnName = mi.Name;
if (mapper != null && !mapper.MapMemberToColumn(mi, ref pc.ColumnName, ref pc.ResultColumn))
continue;
}
// Store it
Columns.Add(pc.ColumnName, pc);
}
// Trim trailing slash if built using Property names
TableInfo.PrimaryKey = TableInfo.PrimaryKey.TrimEnd(',');
// Build column list for automatic select
QueryColumns = (from c in Columns where !c.Value.ResultColumn select c.Key).ToArray();
}
示例3: FluentMappingsPocoData
public FluentMappingsPocoData(Type t, TypeDefinition typeConfig, IMapper mapper, Cache<string, Type> aliasCache)
{
AliasToType = aliasCache;
Mapper = mapper;
type = t;
TableInfo = new TableInfo();
// Get the table name
var a = typeConfig.TableName ?? "";
TableInfo.TableName = a.Length == 0 ? t.Name : a;
// Get the primary key
a = typeConfig.PrimaryKey ?? "";
TableInfo.PrimaryKey = a.Length == 0 ? "ID" : a;
a = typeConfig.SequenceName ?? "";
TableInfo.SequenceName = a.Length == 0 ? null : a;
TableInfo.AutoIncrement = typeConfig.AutoIncrement ?? true;
// Set autoincrement false if primary key has multiple columns
TableInfo.AutoIncrement = TableInfo.AutoIncrement ? !TableInfo.PrimaryKey.Contains(',') : TableInfo.AutoIncrement;
// Call column mapper
if (mapper != null)
mapper.GetTableInfo(t, TableInfo);
var alias = CreateAlias(type.Name, type);
TableInfo.AutoAlias = alias;
var index = 0;
// Work out bound properties
bool explicitColumns = typeConfig.ExplicitColumns ?? false;
Columns = new Dictionary<string, PocoColumn>(StringComparer.OrdinalIgnoreCase);
var originalPK = TableInfo.PrimaryKey.Split(',');
foreach (var mi in ReflectionUtils.GetFieldsAndPropertiesForClasses(t))
{
// Work out if properties is to be included
var isColumnDefined = typeConfig.ColumnConfiguration.ContainsKey(mi.Name);
if (explicitColumns && !isColumnDefined) continue;
if (isColumnDefined && (typeConfig.ColumnConfiguration[mi.Name].IgnoreColumn.HasValue && typeConfig.ColumnConfiguration[mi.Name].IgnoreColumn.Value))
continue;
var pc = new PocoColumn();
pc.TableInfo = TableInfo;
pc.MemberInfo = mi;
pc.AutoAlias = alias + "_" + index++;
// Work out the DB column name
if (isColumnDefined)
{
var colattr = typeConfig.ColumnConfiguration[mi.Name];
pc.ColumnName = colattr.DbColumnName;
pc.ColumnAlias = colattr.DbColumnAlias;
if (colattr.ResultColumn.HasValue && colattr.ResultColumn.Value)
pc.ResultColumn = true;
else if (colattr.VersionColumn.HasValue && colattr.VersionColumn.Value)
{
pc.VersionColumn = true;
pc.VersionColumnType = colattr.VersionColumnType ?? VersionColumnType.Number;
}
else if (colattr.ComputedColumn.HasValue && colattr.ComputedColumn.Value)
pc.ComputedColumn = true;
if (colattr.ForceUtc.HasValue && colattr.ForceUtc.Value)
pc.ForceToUtc = true;
for (int i = 0; i < originalPK.Length; i++)
{
if (originalPK[i].Equals(mi.Name, StringComparison.OrdinalIgnoreCase))
originalPK[i] = (pc.ColumnName ?? mi.Name);
}
pc.ColumnType = colattr.DbColumnType;
}
if (pc.ColumnName == null)
{
pc.ColumnName = mi.Name;
if (mapper != null && !mapper.MapMemberToColumn(mi, ref pc.ColumnName, ref pc.ResultColumn))
continue;
}
// Store it
if (!Columns.ContainsKey(pc.ColumnName))
Columns.Add(pc.ColumnName, pc);
}
// Recombine the primary key
TableInfo.PrimaryKey = String.Join(",", originalPK);
// Build column list for automatic select
QueryColumns = Columns.Where(x => !x.Value.ResultColumn).ToArray();
}