本文整理汇总了C#中IEntityMapping.Get方法的典型用法代码示例。如果您正苦于以下问题:C# IEntityMapping.Get方法的具体用法?C# IEntityMapping.Get怎么用?C# IEntityMapping.Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEntityMapping
的用法示例。
在下文中一共展示了IEntityMapping.Get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetInsertResult
public virtual Expression GetInsertResult(IEntityMapping mapping, Expression instance, LambdaExpression selector, Dictionary<MemberInfo, Expression> map)
{
var tableAlias = new TableAlias();
var tex = new TableExpression(tableAlias, mapping);
var aggregator = Aggregator.GetAggregator(selector.Body.Type, typeof(IEnumerable<>).MakeGenericType(selector.Body.Type));
Expression where = null;
DeclarationCommand genIdCommand = null;
var generatedIds = mapping.PrimaryKeys.Where(m => m.IsPrimaryKey && m.IsGenerated).ToList();
if (generatedIds.Count > 0)
{
if (map == null || !generatedIds.Any(m => map.ContainsKey(m.Member)))
{
var localMap = new Dictionary<MemberInfo, Expression>();
genIdCommand = this.GetGeneratedIdCommand(mapping, generatedIds, localMap);
map = localMap;
}
// is this just a retrieval of one generated id member?
var mex = selector.Body as MemberExpression;
if (mex != null)
{
var id = mapping.Get(mex.Member);
if (id != null && id.IsPrimaryKey && id.IsGenerated)
{
if (genIdCommand != null)
{
// just use the select from the genIdCommand
return new ProjectionExpression(
genIdCommand.Source,
new ColumnExpression(mex.Type, genIdCommand.Variables[0].SqlType, genIdCommand.Source.Alias, genIdCommand.Source.Columns[0].Name),
aggregator
);
}
else
{
TableAlias alias = new TableAlias();
var colType = id.SqlType;
return new ProjectionExpression(
new SelectExpression(alias, new[] { new ColumnDeclaration("", map[mex.Member], colType) }, null, null),
new ColumnExpression(mex.Member.GetMemberType(), colType, alias, ""),
aggregator
);
}
}
where = generatedIds.Select((m, i) =>
this.GetMemberExpression(tex, mapping, m.Member).Equal(map[m.Member])
).Aggregate((x, y) => x.And(y));
}
}
else
{
where = this.GetIdentityCheck(tex, mapping, instance);
}
Expression typeProjector = this.GetEntityExpression(tex, mapping);
Expression selection = DbExpressionReplacer.Replace(selector.Body, selector.Parameters[0], typeProjector);
TableAlias newAlias = new TableAlias();
var pc = ColumnProjector.ProjectColumns(selection, null, newAlias, tableAlias);
var pe = new ProjectionExpression(
new SelectExpression(newAlias, pc.Columns, tex, where),
pc.Projector,
aggregator
);
if (genIdCommand != null)
{
return new BlockCommand(genIdCommand, pe);
}
return pe;
}
示例2: GetMemberExpression
public Expression GetMemberExpression(Expression root, IEntityMapping mapping, MemberInfo member)
{
return GetMemberExpression(root, mapping, mapping.Get(member));
}
示例3: GetMemberExpression
public Expression GetMemberExpression(Expression root, IEntityMapping entity, MemberInfo member)
{
return GetMemberExpression(root, entity, entity.Get(member));
}