I'm working on an EF7 provider for PostgreSQL (with Npgsql), it's my very first foray into the EF codebase so I hope I won't be saying too much nonsense.
Looking at ReaderModificationCommandBatch.Execute(), I notice that it retrieves the affected rows (in the two ConsumeResultSet* methods). It appears to do this by reading the result of a SELECT @@ROWCOUNT appended by SqlServerSqlGenerator.AppendSelectAffectedCountCommand().
PostgreSQL has no equivalent query; affected row counts are sent within the protocol itself, and are currently exposed on the ADO.NET level via the IDbDataReader.RecordsAffected property. In my NpgsqlModificationCommandBatch I can override Execute() and check against that property, but wanted to make sure I'm going down the right path:
- Is there a special reason to use an SqlServer-specific feature (
SELECT @@ROWCOUNT) rather than the standard ADO.NET API for this? Does this have to do with the fact that RecordsAffected is only supposed to be populated after the reader is closed, and therefore gives the aggregate rows rather than resultset-by-resultset? Note that the PostgreSQL protocol does provide affected rows on a resultset-by-resultset basis, so this information can in theory be exposed to the EF provider if absolutely necessary.
- It seems a bit odd for
ReaderModificationCommandBatch, a generic class within EntityFramework.Relational to encode logic that is so specific to the SqlServer adapter, while at the same time containing other, more generic functionality.
- You should probably consider making
SqlGenerator.AppendSelectAffectedCountCommand virtual rather than abstract.
Thanks for any advice on this...
I'm working on an EF7 provider for PostgreSQL (with Npgsql), it's my very first foray into the EF codebase so I hope I won't be saying too much nonsense.
Looking at
ReaderModificationCommandBatch.Execute(), I notice that it retrieves the affected rows (in the two ConsumeResultSet* methods). It appears to do this by reading the result of aSELECT @@ROWCOUNTappended bySqlServerSqlGenerator.AppendSelectAffectedCountCommand().PostgreSQL has no equivalent query; affected row counts are sent within the protocol itself, and are currently exposed on the ADO.NET level via the IDbDataReader.RecordsAffected property. In my NpgsqlModificationCommandBatch I can override Execute() and check against that property, but wanted to make sure I'm going down the right path:
SELECT @@ROWCOUNT) rather than the standard ADO.NET API for this? Does this have to do with the fact that RecordsAffected is only supposed to be populated after the reader is closed, and therefore gives the aggregate rows rather than resultset-by-resultset? Note that the PostgreSQL protocol does provide affected rows on a resultset-by-resultset basis, so this information can in theory be exposed to the EF provider if absolutely necessary.ReaderModificationCommandBatch, a generic class within EntityFramework.Relational to encode logic that is so specific to the SqlServer adapter, while at the same time containing other, more generic functionality.SqlGenerator.AppendSelectAffectedCountCommandvirtual rather than abstract.Thanks for any advice on this...