/// <summary> /// Executes the operation against the provided data source /// and returns the result. /// </summary> /// <param name="context">Provides the current operation context.</param> public TResult Execute(DbOperationContext context) { Precondition.Require(context, () => Error.ArgumentNull("context")); ValidateOperation(); return(ExecuteInternal(context)); }
/// <summary> /// Executes the operation against the provided data source /// and returns the result. /// </summary> /// <param name="context">Provides the current operation context.</param> protected override TResult ExecuteInternal(DbOperationContext context) { DbCommandDescriptor command = CreateCommand(); Precondition.Require(command, () => Error.CommandIsNotInitialized()); return(ExecuteCommand(context, command)); }
/// <summary> /// Executes the operation against the provided data source /// and returns the result. /// </summary> /// <param name="context">Provides the current operation context.</param> protected override TResult ExecuteInternal(DbOperationContext context) { try { return(base.ExecuteInternal(context)); } finally { context.Cache.Invalidate(Tags); } }
/// <summary> /// Executes the provided <paramref name="command"/> /// against the provided data source and returns the result. /// </summary> /// <param name="context">Provides the current operation context.</param> /// <param name="command">The command instance to execute.</param> protected override TEntity ExecuteCommand(DbOperationContext context, DbCommandDescriptor command) { return(context.Provider.Execute(command).AsDataReader <TEntity>(reader => { if (reader.Read()) { return Materializer.Materialize(reader); } return default(TEntity); })); }
/// <summary> /// Executes the operation against the provided data source /// and returns the result. /// </summary> /// <param name="context">Provides the current operation context.</param> protected override TResult ExecuteInternal(DbOperationContext context) { DbCommandDescriptor command = CreateCommand(); Precondition.Require(command, () => Error.CommandIsNotInitialized()); string cacheKey = CreateCacheKey(command); return(context.Cache.Get <TResult>(cacheKey, () => ExecuteCommand(context, command), DateTime.Now.Add(_expirationTimeout), Tags)); }
/// <summary> /// Executes the provided <paramref name="command"/> /// against the provided data source and returns the result. /// </summary> /// <param name="context">Provides the current operation context.</param> /// <param name="command">The command instance to execute.</param> protected override IEnumerable <TEntity> ExecuteCommand(DbOperationContext context, DbCommandDescriptor command) { return(context.Provider.Execute(command).AsDataReader(reader => { List <TEntity> collection = new List <TEntity>(BufferSize); while (reader.Read()) { collection.Add(Materializer.Materialize(reader)); } return collection; })); }
/// <summary> /// Executes the provided <paramref name="command"/> /// against the provided data source and returns the result. /// </summary> /// <param name="context">Provides the current operation context.</param> /// <param name="command">The command instance to execute.</param> protected override IEnumerable <TEntity> ExecuteCommand(DbOperationContext context, DbCommandDescriptor command) { return(context.Provider.Execute(command).AsDataReader(reader => { List <TEntity> collection = new List <TEntity>(BufferSize); int count = 0; while (reader.Read()) { collection.Add(Materializer.Materialize(reader)); } if (reader.NextResult() && reader.Read()) { count = reader.GetValue <int>(0); } return collection.ToSubset(count); })); }
/// <summary> /// Executes the operation against the provided data source /// and returns the result. /// </summary> /// <param name="context">Provides the current operation context.</param> protected override IEnumerable <TEntity> ExecuteInternal(DbOperationContext context) { context.Cache.Invalidate(Tags); return(base.ExecuteInternal(context)); }
/// <summary> /// Executes the operation against the provided data source. /// </summary> /// <param name="context">Provides the current operation context.</param> void IContextualOperation <DbOperationContext> .Execute(DbOperationContext context) { Execute(context); }
/// <summary> /// When overridden in a derived class, executes the operation /// against the provided data source. /// </summary> /// <param name="context">Provides the current operation context.</param> protected abstract TResult ExecuteInternal(DbOperationContext context);
/// <summary> /// Executes the operation against the provided data source /// and returns a number of rows affected. /// </summary> /// <param name="context">Provides the current operation context.</param> /// <param name="command">The command instance to execute.</param> protected override int ExecuteCommand(DbOperationContext context, DbCommandDescriptor command) { return(context.Provider.Execute(command).AsNonQuery()); }
/// <summary> /// When overridden in a derived class, executes the provided <paramref name="command"/> /// against the provided data source and returns the result. /// </summary> /// <param name="context">Provides the current operation context.</param> /// <param name="command">The command instance to execute.</param> protected abstract TResult ExecuteCommand(DbOperationContext context, DbCommandDescriptor command);
/// <summary> /// Executes the operation against the provided data source /// and returns the scalar result. /// </summary> /// <param name="context">Provides the current operation context.</param> /// <param name="command">The command instance to execute.</param> protected override TResult ExecuteCommand(DbOperationContext context, DbCommandDescriptor command) { return(context.Provider.Execute(command).AsScalar <TResult>()); }