/// <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 Serializer.Deserialize(reader); // TODO: Этого мало, необходимо сделать обработку ResultShape'ов. } return default(TEntity); })); }
/// <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(Serializer.Deserialize(reader)); // TODO: Этого мало, необходимо сделать обработку ResultShape'ов. } 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(Serializer.Deserialize(reader)); // TODO: Добавить поддержку ResultShapes. } if (reader.NextResult() && reader.Read()) { count = reader.GetValue <int>(0); } return collection.ToSubset(count); })); }
protected override int ExecuteCommand(DbOperationContext context, DbCommandDescriptor command) { return(context.Provider.Execute(command).AsNonQuery()); }
protected override DbQueryResult ExecuteCommand(DbOperationContext context, DbCommandDescriptor command) { return(context.Provider.Execute(command).AsDataReader(reader => new DbQueryResult(reader))); }