public EntityInfo TargetEntity; //for delete, insert, update #endregion Fields #region Constructors public LinqCommand(EntityQuery query, LinqCommandType commandType, LinqCommandKind kind, EntityInfo targetEntity) { Kind = kind; CommandType = commandType; Query = query; TargetEntity = targetEntity; }
internal LinqCommand(LinqCommandInfo info, EntityInfo targetEntity, object[] parameterValues) { Info = info; Kind = info.CommandKind; CommandType = info.CommandType; TargetEntity = targetEntity; ParameterValues = parameterValues; Util.Check(ParameterValues.Length == info.Lambda.Parameters.Count, "Parameter values count ({0}) does not match parameter count ({1}) in lambda: {2}.", parameterValues.Length, Info.Lambda.Parameters.Count, Info.Lambda); }
public LinqCommandInfo(LinqCommand command, QueryOptions options, LinqCommandFlags flags, List<Type> entityTypes, string cacheKey, List<ParameterExpression> externalParameters, List<LambdaExpression> includes) { CommandType = command.CommandType; CommandKind = command.Kind; Options = options; Flags = flags; EntityTypes = entityTypes; CacheKey = cacheKey; ExternalParameters = externalParameters; Includes = includes; }
/// <summary>Executes non-query operation of specified type based on LINQ query. See concrete methods for specific command types /// for more information and requirements to base query in each case. </summary> /// <typeparam name="TEntity">Entity type.</typeparam> /// <param name="query">Base query.</param> /// <param name="commandType">Command type (insert, update or delete).</param> /// <returns></returns> public static int ExecuteNonQuery <TEntity>(this IQueryable query, LinqCommandType commandType) { var entQuery = query as EntityQuery; var prov = entQuery.Provider as EntityQueryProvider; var session = prov.Session; Util.Check(session != null, "Cannot execute query not associated with active entity session."); var targetEnt = session.Context.App.Model.GetEntityInfo(typeof(TEntity)); var command = new LinqCommand(entQuery, commandType, LinqCommandKind.DynamicSql, targetEnt); var objResult = session.ExecuteLinqCommand(command); return((int)objResult); }
public LinqCommandInfo(LinqCommand command, QueryOptions options, LinqCommandFlags flags, List <Type> entityTypes, string cacheKey, List <ParameterExpression> externalParameters, List <LambdaExpression> includes) { CommandType = command.CommandType; CommandKind = command.Kind; Options = options; Flags = flags; EntityTypes = entityTypes; CacheKey = cacheKey; ExternalParameters = externalParameters; Includes = includes; }
public static void ScheduleNonQuery <TEntity>(this IEntitySession session, IQueryable query, LinqCommandType commandType, CommandSchedule schedule = CommandSchedule.TransactionEnd) { var entQuery = query as EntityQuery; var model = session.Context.App.Model; Util.Check(entQuery != null, "query parameter should an EntityQuery."); var prov = entQuery.Provider as EntityQueryProvider; var targetEnt = model.GetEntityInfo(typeof(TEntity)); Util.Check(targetEnt != null, "Generic parameter {0} is not an entity registered in the Model.", typeof(TEntity)); var command = new LinqCommand(entQuery, commandType, LinqCommandKind.DynamicSql, targetEnt); LinqCommandAnalyzer.Analyze(model, command); command.EvaluateLocalValues((EntitySession)session); var scheduledCommand = new ScheduledLinqCommand() { Command = command, Schedule = schedule }; var entSession = (EntitySession)session; entSession.ScheduledCommands.Add(scheduledCommand); }
public LinqCommand(EntityQuery query, LinqCommandType commandType, LinqCommandKind kind, EntityInfo targetEntity) { Kind = kind; CommandType = commandType; Query = query; TargetEntity = targetEntity; }