本文整理汇总了C#中TableExpression类的典型用法代码示例。如果您正苦于以下问题:C# TableExpression类的具体用法?C# TableExpression怎么用?C# TableExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TableExpression类属于命名空间,在下文中一共展示了TableExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:rdrawsky,项目名称:iqtoolkit,代码行数:26,代码来源:AdvancedMapping.cs
示例2: VisitTable
protected override Expression VisitTable(TableExpression table)
{
var columns = CurrentScope.Keys.Where(ce => ce.Alias == table.Alias).ToList();
CurrentScope.SetRange(columns, columns.Cast<Expression>());
return table;
}
开发者ID:nuub666,项目名称:framework,代码行数:8,代码来源:QueryRebinder.cs
示例3: 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);
}
开发者ID:firestrand,项目名称:IQToolkit,代码行数:19,代码来源:BasicMapper.cs
示例4: CompareTable
protected virtual bool CompareTable(TableExpression a, TableExpression b)
{
return a.Name == b.Name;
}
开发者ID:jogibear9988,项目名称:IQToolkit,代码行数:4,代码来源:DbExpressionComparer.cs
示例5: VisitTable
protected virtual Expression VisitTable(TableExpression table)
{
return table;
}
开发者ID:RyanDansie,项目名称:SubSonic-3.0,代码行数:4,代码来源:DbExpressionVisitor.cs
示例6: VisitTable
protected override Expression VisitTable(TableExpression table)
{
TableAlias newAlias = new TableAlias();
this.map[table.Alias] = newAlias;
return new TableExpression(newAlias, table.Entity, table.Name);
}
开发者ID:jogibear9988,项目名称:IQToolkit,代码行数:6,代码来源:QueryDuplicator.cs
示例7: GetDeleteExpression
public virtual Expression GetDeleteExpression(IEntityMapping mapping, Expression instance, LambdaExpression deleteCheck)
{
TableExpression table = new TableExpression(new TableAlias(), mapping);
Expression where = null;
if (instance != null)
where = this.GetIdentityCheck(table, mapping, instance);
if (deleteCheck != null)
{
Expression row = this.GetEntityExpression(table, mapping);
Expression pred = DbExpressionReplacer.Replace(deleteCheck.Body, deleteCheck.Parameters[0], row);
where = (where != null) ? where.And(pred) : pred;
}
bool supportsVersionCheck = false;
if (mapping.Version != null && instance != null)
{
//var versionValue = GetVersionValue(entity, instance);
//var versionCheck = GetMemberExpression(table, entity, entity.Version).Equal(Expression.Constant(versionValue));
//where = (where != null) ? where.And(versionCheck) : versionCheck;
var version = mapping.Version;
var versionValue = GetVersionValue(mapping, instance);
var versionExp = Expression.Constant(versionValue, version.MemberType);
var memberExpression = GetMemberExpression(table, mapping, mapping.Version);
if (version.MemberType.IsNullable())
{
var versionCheck = versionValue == null ? (Expression)memberExpression.Equal(Expression.Constant(null, version.MemberType))
: memberExpression.Equal(versionExp);
where = (where != null) ? where.And(versionCheck) : versionCheck;
}
else
{
var versionCheck = memberExpression.Equal(versionExp);
where = (where != null) ? where.And(versionCheck) : versionCheck;
}
supportsVersionCheck = true;
}
object o = null;
var c = instance as ConstantExpression;
if (c != null)
o = c.Value;
return new DeleteCommand(table, where, o, supportsVersionCheck);
}
开发者ID:jaykizhou,项目名称:elinq,代码行数:49,代码来源:DbExpressionBuilder.cs
示例8: GetDependentGeneratedVariableDeclaration
// make a variable declaration / initialization for dependent generated values
private CommandExpression GetDependentGeneratedVariableDeclaration(MappingEntity entity, MappingTable table, List<MemberInfo> members, Expression instance, Dictionary<MemberInfo, Expression> map)
{
// first make command that retrieves the generated ids if any
DeclarationCommand genIdCommand = null;
var generatedIds = this.mapping.GetMappedMembers(entity).Where(m => this.mapping.IsPrimaryKey(entity, m) && this.mapping.IsGenerated(entity, m)).ToList();
if (generatedIds.Count > 0)
{
genIdCommand = this.GetGeneratedIdCommand(entity, members, map);
// if that's all there is then just return the generated ids
if (members.Count == generatedIds.Count)
{
return genIdCommand;
}
}
// next make command that retrieves the generated members
// only consider members that were not generated ids
members = members.Except(generatedIds).ToList();
var tableAlias = new TableAlias();
var tex = new TableExpression(tableAlias, entity, this.mapping.GetTableName(table));
Expression where = null;
if (generatedIds.Count > 0)
{
where = generatedIds.Select((m, i) =>
this.GetMemberExpression(tex, entity, m).Equal(map[m])
).Aggregate((x, y) => x.And(y));
}
else
{
where = this.GetIdentityCheck(tex, entity, instance);
}
TableAlias selectAlias = new TableAlias();
var columns = new List<ColumnDeclaration>();
var variables = new List<VariableDeclaration>();
foreach (var mi in members)
{
ColumnExpression col = (ColumnExpression)this.GetMemberExpression(tex, entity, mi);
columns.Add(new ColumnDeclaration(this.mapping.GetColumnName(entity, mi), col, col.QueryType));
ColumnExpression vcol = new ColumnExpression(col.Type, col.QueryType, selectAlias, col.Name);
variables.Add(new VariableDeclaration(mi.Name, col.QueryType, vcol));
map.Add(mi, new VariableExpression(mi.Name, col.Type, col.QueryType));
}
var genMembersCommand = new DeclarationCommand(variables, new SelectExpression(selectAlias, columns, tex, where));
if (genIdCommand != null)
{
return new BlockCommand(genIdCommand, genMembersCommand);
}
return genMembersCommand;
}
开发者ID:rdrawsky,项目名称:iqtoolkit,代码行数:57,代码来源:AdvancedMapping.cs
示例9: GetInsertExpression
public virtual Expression GetInsertExpression(IEntityMapping mapping, Expression instance, LambdaExpression selector)
{
var tableAlias = new TableAlias();
var table = new TableExpression(tableAlias, mapping);
var assignments = this.GetInsertColumnAssignments(table, instance, mapping, m => !m.IsGenerated && !m.IsVersion).ToArray();
object o = null;
var c = instance as ConstantExpression;
if (c != null)
o = c.Value;
if (selector != null)
{
return new BlockCommand(
new InsertCommand(table, assignments, o),
this.GetInsertResult(mapping, instance, selector, null)
);
}
return new InsertCommand(table, assignments, o);
}
开发者ID:jaykizhou,项目名称:elinq,代码行数:21,代码来源:DbExpressionBuilder.cs
示例10: VisitTable
protected internal override Expression VisitTable(TableExpression table)
{
this.aliases.Add(table.Alias);
return base.VisitTable(table);
}
开发者ID:rondoo,项目名称:framework,代码行数:5,代码来源:AliasGatherer.cs
示例11: GetUpdateExpression
public virtual Expression GetUpdateExpression(IEntityMapping mapping, Expression instance, LambdaExpression updateCheck, LambdaExpression selector, Expression @else)
{
var tableAlias = new TableAlias();
var table = new TableExpression(tableAlias, mapping);
var where = this.GetIdentityCheck(table, mapping, instance);
if (updateCheck != null)
{
Expression typeProjector = this.GetEntityExpression(table, mapping);
Expression pred = DbExpressionReplacer.Replace(updateCheck.Body, updateCheck.Parameters[0], typeProjector);
where = where != null ? where.And(pred) : pred;
}
var assignments = this.GetColumnAssignments(table, instance, mapping, m => m.IsUpdatable && !m.IsVersion);
var version = mapping.Version;
bool supportsVersionCheck = false;
if (version != null)
{
var versionValue = GetVersionValue(mapping, instance);
var versionExp = Expression.Constant(versionValue, version.MemberType);
var memberExpression = GetMemberExpression(table, mapping, mapping.Version);
var versionCheck = memberExpression.Equal(versionExp);
where = (where != null) ? where.And(versionCheck) : versionCheck;
if (version.MemberType.IsNullable())
{
var versionAssignment = new ColumnAssignment(
memberExpression as ColumnExpression,
versionValue == null ?
(Expression)Expression.Constant(1, version.MemberType)
: Expression.Add(memberExpression, Expression.Constant(1, version.MemberType))
);
assignments.Add(versionAssignment);
supportsVersionCheck = true;
}
else
{
var versionAssignment = new ColumnAssignment(
memberExpression as ColumnExpression,
Expression.Add(memberExpression, Expression.Constant(1, version.MemberType))
);
assignments.Add(versionAssignment);
supportsVersionCheck = true;
}
}
object o = null;
var c = instance as ConstantExpression;
if (c != null)
o = c.Value;
Expression update = new UpdateCommand(table, where, o, supportsVersionCheck, assignments);
if (selector != null)
{
return new BlockCommand(
update,
new IFCommand(
this.GetRowsAffectedExpression(update).GreaterThan(Expression.Constant(0)),
this.GetUpdateResult(mapping, instance, selector),
@else
)
);
}
else if (@else != null)
{
return new BlockCommand(
update,
new IFCommand(
this.GetRowsAffectedExpression(update).LessThanOrEqual(Expression.Constant(0)),
@else,
null
)
);
}
else
{
return update;
}
}
开发者ID:jaykizhou,项目名称:elinq,代码行数:81,代码来源:DbExpressionBuilder.cs
示例12: VisitTable
protected override Expression VisitTable(TableExpression table)
{
if (gatheredKeys != null)
gatheredKeys.Add(table.GetIdExpression());
return table;
}
开发者ID:nuub666,项目名称:framework,代码行数:7,代码来源:OrderByRewriter.cs
示例13: GroupByExpression
private GroupByExpression(TableExpression tableExpression)
: base(ExpressionType, tableExpression)
{
Table = tableExpression;
}
开发者ID:nlhepler,项目名称:mono,代码行数:5,代码来源:GroupByExpression.cs
示例14: UpdateDelete
protected DeleteCommand UpdateDelete(DeleteCommand delete, TableExpression table, Expression where)
{
if (table != delete.Table || where != delete.Where)
{
return new DeleteCommand(table, where);
}
return delete;
}
开发者ID:bisand,项目名称:NetCouch,代码行数:8,代码来源:DbExpressionVisitor.cs
示例15: UpdateUpdate
protected UpdateCommand UpdateUpdate(UpdateCommand update, TableExpression table, Expression where, IEnumerable<ColumnAssignment> assignments)
{
if (table != update.Table || where != update.Where || assignments != update.Assignments)
{
return new UpdateCommand(table, where, assignments);
}
return update;
}
开发者ID:bisand,项目名称:NetCouch,代码行数:8,代码来源:DbExpressionVisitor.cs
示例16: UpdateInsert
protected InsertCommand UpdateInsert(InsertCommand insert, TableExpression table, IEnumerable<ColumnAssignment> assignments)
{
if (table != insert.Table || assignments != insert.Assignments)
{
return new InsertCommand(table, assignments);
}
return insert;
}
开发者ID:bisand,项目名称:NetCouch,代码行数:8,代码来源:DbExpressionVisitor.cs
示例17: VisitTable
protected override Expression VisitTable(TableExpression table)
{
if (aliasMap.ContainsKey(table.Alias))
return new TableExpression(aliasMap[table.Alias], table.Table);
return table;
}
开发者ID:nuub666,项目名称:framework,代码行数:6,代码来源:AliasReplacer.cs
示例18: GetQueryExpression
public override ProjectionExpression GetQueryExpression(MappingEntity entity)
{
var tables = this.mapping.GetTables(entity);
if (tables.Count <= 1)
{
return base.GetQueryExpression(entity);
}
var aliases = new Dictionary<string, TableAlias>();
MappingTable rootTable = tables.Single(ta => !this.mapping.IsExtensionTable(ta));
var tex = new TableExpression(new TableAlias(), entity, this.mapping.GetTableName(rootTable));
aliases.Add(this.mapping.GetAlias(rootTable), tex.Alias);
Expression source = tex;
foreach (MappingTable table in tables.Where(t => this.mapping.IsExtensionTable(t)))
{
TableAlias joinedTableAlias = new TableAlias();
string extensionAlias = this.mapping.GetAlias(table);
aliases.Add(extensionAlias, joinedTableAlias);
List<string> keyColumns = this.mapping.GetExtensionKeyColumnNames(table).ToList();
List<MemberInfo> relatedMembers = this.mapping.GetExtensionRelatedMembers(table).ToList();
string relatedAlias = this.mapping.GetExtensionRelatedAlias(table);
TableAlias relatedTableAlias;
aliases.TryGetValue(relatedAlias, out relatedTableAlias);
TableExpression joinedTex = new TableExpression(joinedTableAlias, entity, this.mapping.GetTableName(table));
Expression cond = null;
for (int i = 0, n = keyColumns.Count; i < n; i++)
{
var memberType = TypeHelper.GetMemberType(relatedMembers[i]);
var colType = this.GetColumnType(entity, relatedMembers[i]);
var relatedColumn = new ColumnExpression(memberType, colType, relatedTableAlias, this.mapping.GetColumnName(entity, relatedMembers[i]));
var joinedColumn = new ColumnExpression(memberType, colType, joinedTableAlias, keyColumns[i]);
var eq = joinedColumn.Equal(relatedColumn);
cond = (cond != null) ? cond.And(eq) : eq;
}
source = new JoinExpression(JoinType.SingletonLeftOuter, source, joinedTex, cond);
}
var columns = new List<ColumnDeclaration>();
this.GetColumns(entity, aliases, columns);
SelectExpression root = new SelectExpression(new TableAlias(), columns, source, null);
var existingAliases = aliases.Values.ToArray();
Expression projector = this.GetEntityExpression(root, entity);
var selectAlias = new TableAlias();
var pc = ColumnProjector.ProjectColumns(this.Translator.Linguist.Language, projector, null, selectAlias, root.Alias);
var proj = new ProjectionExpression(
new SelectExpression(selectAlias, pc.Columns, root, null),
pc.Projector
);
return (ProjectionExpression)this.Translator.Police.ApplyPolicy(proj, entity.ElementType);
}
开发者ID:rdrawsky,项目名称:iqtoolkit,代码行数:58,代码来源:AdvancedMapping.cs
示例19: KeysTable
private static IEnumerable<ColumnExpression> KeysTable(TableExpression table)
{
yield return new ColumnExpression(typeof(int), table.Alias, SqlBuilder.PrimaryKeyName) ;
}
开发者ID:nuub666,项目名称:framework,代码行数:4,代码来源:ChildProjectionFlattener.cs
示例20: GetQueryExpression
public virtual ProjectionExpression GetQueryExpression(IEntityMapping mapping)
{
Expression projector;
TableAlias selectAlias;
ProjectedColumns pc;
ProjectionExpression proj;
var tableAlias = new TableAlias();
selectAlias = new TableAlias();
var table = new TableExpression(tableAlias, mapping);
projector = this.GetEntityExpression(table, mapping);
pc = ColumnProjector.ProjectColumns(projector, null, selectAlias, tableAlias);
proj = new ProjectionExpression(
new SelectExpression(selectAlias, pc.Columns, table, null),
pc.Projector
);
return (ProjectionExpression)ApplyPolicy(proj, mapping.EntityType);
}
开发者ID:jaykizhou,项目名称:elinq,代码行数:21,代码来源:DbExpressionBuilder.cs
注:本文中的TableExpression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论