本文整理汇总了C#中IQToolkit.Data.Common.MappingEntity类的典型用法代码示例。如果您正苦于以下问题:C# MappingEntity类的具体用法?C# MappingEntity怎么用?C# MappingEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MappingEntity类属于IQToolkit.Data.Common命名空间,在下文中一共展示了MappingEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDeleteExpression
public override Expression GetDeleteExpression(MappingEntity entity, Expression instance, LambdaExpression deleteCheck)
{
var tables = this.mapping.GetTables(entity);
if (tables.Count < 2)
{
return base.GetDeleteExpression(entity, instance, deleteCheck);
}
var commands = new List<Expression>();
foreach (var table in this.GetDependencyOrderedTables(entity).Reverse())
{
TableExpression tex = new TableExpression(new TableAlias(), entity, this.mapping.GetTableName(table));
var where = this.GetIdentityCheck(tex, entity, instance);
commands.Add(new DeleteCommand(tex, where));
}
Expression block = new BlockCommand(commands);
if (deleteCheck != null)
{
var test = this.GetEntityStateTest(entity, instance, deleteCheck);
return new IFCommand(test, block, null);
}
return block;
}
示例2: GetEntityExpression
public override EntityExpression GetEntityExpression(Expression root, MappingEntity entity)
{
// must be some complex type constructed from multiple columns
var assignments = new List<EntityAssignment>();
foreach (MemberInfo mi in this.mapping.GetMappedMembers(entity))
{
if (!this.mapping.IsAssociationRelationship(entity, mi))
{
Expression me;
if (this.mapping.IsNestedEntity(entity, mi))
{
me = this.GetEntityExpression(root, this.mapping.GetRelatedEntity(entity, mi));
}
else
{
me = this.GetMemberExpression(root, entity, mi);
}
if (me != null)
{
assignments.Add(new EntityAssignment(mi, me));
}
}
}
return new EntityExpression(entity, this.BuildEntityExpression(entity, assignments));
}
示例3: GetDependencyOrderedTables
public virtual IEnumerable<MappingTable> GetDependencyOrderedTables(MappingEntity entity)
{
var lookup = _mapping.GetTables(entity).ToLookup(t => _mapping.GetAlias(t));
return
_mapping.GetTables(entity).Sort(
t => _mapping.IsExtensionTable(t) ? lookup[_mapping.GetExtensionRelatedAlias(t)] : null);
}
示例4: GetColumnName
public override string GetColumnName(MappingEntity entity, MemberInfo member)
{
var dbMapping = (DbMappingEntity) entity;
var memberMapping = dbMapping.TypeMapping.GetMember(member.Name);
if (memberMapping == null)
return null;
return memberMapping.ColumnName;
}
示例5: GetColumnType
/// <summary>
/// The query language specific type for the column
/// </summary>
/// <param name="member"></param>
/// <returns></returns>
public virtual QueryType GetColumnType(MappingEntity entity, MemberInfo member)
{
string dbType = this.mapping.GetColumnDbType(entity, member);
if (dbType != null)
{
return this.translator.Linguist.Language.TypeSystem.Parse(dbType);
}
return this.translator.Linguist.Language.TypeSystem.GetColumnType(TypeHelper.GetMemberType(member));
}
示例6: GetColumnDbType
public override string GetColumnDbType(MappingEntity entity, MemberInfo member)
{
var dbMapping = (DbMappingEntity)entity;
var mapppedMember = dbMapping.TypeMapping.GetMember(member.Name);
if (mapppedMember == null)
return null;
// TODO: Check if here we should provide the full version of the type of just the name
return mapppedMember.ColumnType.TypeCode.ToString();
}
示例7: GetMappedMembers
public override IEnumerable<MemberInfo> GetMappedMembers(MappingEntity entity)
{
DbTableEntityMapping tm = ((SimpleMappingEntity)entity).TableTypeMapping;
foreach (DbFieldMemberInfo mi in tm.DbFieldMemberInfos.Values)
{
yield return mi.Member;
}
foreach (AssociationInfo ai in tm.AssociationInfos.Values)
{
yield return ai.Member;
}
}
示例8: CloneEntity
public override object CloneEntity(MappingEntity entity, object instance)
{
var clone = System.Runtime.Serialization.FormatterServices.GetUninitializedObject(entity.EntityType);
foreach (var mi in this.GetMappedMembers(entity))
{
if (this.IsColumn(entity, mi))
{
mi.SetValue(clone, mi.GetValue(instance));
}
}
return clone;
}
示例9: FindDbField
public DbField FindDbField(MappingEntity entity, MemberInfo member)
{
DbTableEntityMapping tm = ((SimpleMappingEntity)entity).TableTypeMapping;
string pName;
if (entity.EntityType.Equals(member.ReflectedType))
pName = member.Name;
else
pName = DbTableEntityMapping.GetFullMemberName(member.DeclaringType.Name, member.Name);
if (tm.DbFieldInfos.ContainsKey(pName))
return tm.DbFieldInfos[pName];
return null;
}
示例10: GetDeleteExpression
public override Expression GetDeleteExpression(MappingEntity entity, Expression instance, LambdaExpression deleteCheck)
{
TableExpression table = new TableExpression(new TableAlias(), entity, this.mapping.GetTableName(entity));
Expression where = null;
if (instance != null)
{
where = this.GetIdentityCheck(table, entity, instance);
}
if (deleteCheck != null)
{
Expression row = this.GetEntityExpression(table, entity);
Expression pred = DbExpressionReplacer.Replace(deleteCheck.Body, deleteCheck.Parameters[0], row);
where = (where != null) ? where.And(pred) : pred;
}
return new DeleteCommand(table, where);
}
示例11: IsNestedEntity
public abstract bool IsNestedEntity(MappingEntity entity, MemberInfo member);
示例12: GetTables
public abstract IList<MappingTable> GetTables(MappingEntity entity);
示例13: GetAlias
public abstract string GetAlias(MappingEntity entity, MemberInfo member);
示例14: GetRelatedColumnAssignments
private IEnumerable<ColumnAssignment> GetRelatedColumnAssignments(Expression expr, MappingEntity entity, MappingTable table, Dictionary<MemberInfo, Expression> map)
{
if (this.mapping.IsExtensionTable(table))
{
var keyColumns = this.mapping.GetExtensionKeyColumnNames(table).ToArray();
var relatedMembers = this.mapping.GetExtensionRelatedMembers(table).ToArray();
for (int i = 0, n = keyColumns.Length; i < n; i++)
{
MemberInfo member = relatedMembers[i];
Expression exp = map[member];
yield return new ColumnAssignment((ColumnExpression)this.GetMemberExpression(expr, entity, member), exp);
}
}
}
示例15: GetIdentityCheck
private Expression GetIdentityCheck(TableExpression root, MappingEntity entity, Expression instance, MappingTable table)
{
if (this.mapping.IsExtensionTable(table))
{
var keyColNames = this.mapping.GetExtensionKeyColumnNames(table).ToArray();
var relatedMembers = this.mapping.GetExtensionRelatedMembers(table).ToArray();
Expression where = null;
for (int i = 0, n = keyColNames.Length; i < n; i++)
{
var relatedMember = relatedMembers[i];
var cex = new ColumnExpression(TypeHelper.GetMemberType(relatedMember), this.GetColumnType(entity, relatedMember), root.Alias, keyColNames[n]);
var nex = this.GetMemberExpression(instance, entity, relatedMember);
var eq = cex.Equal(nex);
where = (where != null) ? where.And(eq) : where;
}
return where;
}
else
{
return base.GetIdentityCheck(root, entity, instance);
}
}