Exemple #1
0
        public SqlServerDataProvider(string name, SqlServerVersion version)
            : base(name, (MappingSchema)null)
        {
            Version = version;

            if (version == SqlServerVersion.v2000)
            {
                SqlProviderFlags.AcceptsTakeAsParameter   = false;
                SqlProviderFlags.IsSkipSupported          = false;
                SqlProviderFlags.IsCountSubQuerySupported = false;
            }
            else
            {
                SqlProviderFlags.IsApplyJoinSupported = true;
                SqlProviderFlags.TakeHintsSupported   = TakeHints.Percent | TakeHints.WithTies;
                SqlProviderFlags.IsCommonTableExpressionsSupported = version >= SqlServerVersion.v2008;
            }

            SetCharField("char", (r, i) => r.GetString(i).TrimEnd(' '));
            SetCharField("nchar", (r, i) => r.GetString(i).TrimEnd(' '));
            SetCharFieldToType <char>("char", (r, i) => DataTools.GetChar(r, i));
            SetCharFieldToType <char>("nchar", (r, i) => DataTools.GetChar(r, i));

            if (!Configuration.AvoidSpecificDataProviderAPI)
            {
                SetProviderField <SqlDataReader, SqlBinary, SqlBinary>((r, i) => r.GetSqlBinary(i));
                SetProviderField <SqlDataReader, SqlBoolean, SqlBoolean>((r, i) => r.GetSqlBoolean(i));
                SetProviderField <SqlDataReader, SqlByte, SqlByte>((r, i) => r.GetSqlByte(i));
                SetProviderField <SqlDataReader, SqlDateTime, SqlDateTime>((r, i) => r.GetSqlDateTime(i));
                SetProviderField <SqlDataReader, SqlDecimal, SqlDecimal>((r, i) => r.GetSqlDecimal(i));
                SetProviderField <SqlDataReader, SqlDouble, SqlDouble>((r, i) => r.GetSqlDouble(i));
                SetProviderField <SqlDataReader, SqlGuid, SqlGuid>((r, i) => r.GetSqlGuid(i));
                SetProviderField <SqlDataReader, SqlInt16, SqlInt16>((r, i) => r.GetSqlInt16(i));
                SetProviderField <SqlDataReader, SqlInt32, SqlInt32>((r, i) => r.GetSqlInt32(i));
                SetProviderField <SqlDataReader, SqlInt64, SqlInt64>((r, i) => r.GetSqlInt64(i));
                SetProviderField <SqlDataReader, SqlMoney, SqlMoney>((r, i) => r.GetSqlMoney(i));
                SetProviderField <SqlDataReader, SqlSingle, SqlSingle>((r, i) => r.GetSqlSingle(i));
                SetProviderField <SqlDataReader, SqlString, SqlString>((r, i) => r.GetSqlString(i));
                SetProviderField <SqlDataReader, SqlXml, SqlXml>((r, i) => r.GetSqlXml(i));

                SetProviderField <SqlDataReader, DateTimeOffset>((r, i) => r.GetDateTimeOffset(i));
                SetProviderField <SqlDataReader, TimeSpan>      ((r, i) => r.GetTimeSpan(i));
            }
            else
            {
                SetProviderField <IDataReader, SqlString, SqlString>((r, i) => r.GetString(i));
            }

            _sqlServer2000SqlOptimizer = new SqlServer2000SqlOptimizer(SqlProviderFlags);
            _sqlServer2005SqlOptimizer = new SqlServer2005SqlOptimizer(SqlProviderFlags);
            _sqlServer2008SqlOptimizer = new SqlServerSqlOptimizer(SqlProviderFlags);
            _sqlServer2012SqlOptimizer = new SqlServer2012SqlOptimizer(SqlProviderFlags);

            SetField <IDataReader, decimal>((r, i) => r.GetDecimal(i));
            SetField <IDataReader, decimal>("money", (r, i) => SqlServerTools.DataReaderGetMoney(r, i));
            SetField <IDataReader, decimal>("smallmoney", (r, i) => SqlServerTools.DataReaderGetMoney(r, i));
            SetField <IDataReader, decimal>("decimal", (r, i) => SqlServerTools.DataReaderGetDecimal(r, i));
        }
        public SqlServerDataProvider(string name, SqlServerVersion version)
            : base(name, null)
        {
            Version = version;

            if (version == SqlServerVersion.v2000)
            {
                SqlProviderFlags.AcceptsTakeAsParameter   = false;
                SqlProviderFlags.IsSkipSupported          = false;
                SqlProviderFlags.IsCountSubQuerySupported = false;
            }
            else
            {
                SqlProviderFlags.IsApplyJoinSupported = true;
            }

            SetCharField("char", (r, i) => r.GetString(i).TrimEnd());
            SetCharField("nchar", (r, i) => r.GetString(i).TrimEnd());

            if (!Configuration.AvoidSpecificDataProviderAPI)
            {
                SetProviderField <SqlDataReader, SqlBinary, SqlBinary>((r, i) => r.GetSqlBinary(i));
                SetProviderField <SqlDataReader, SqlBoolean, SqlBoolean>((r, i) => r.GetSqlBoolean(i));
                SetProviderField <SqlDataReader, SqlByte, SqlByte>((r, i) => r.GetSqlByte(i));
                SetProviderField <SqlDataReader, SqlDateTime, SqlDateTime>((r, i) => r.GetSqlDateTime(i));
                SetProviderField <SqlDataReader, SqlDecimal, SqlDecimal>((r, i) => r.GetSqlDecimal(i));
                SetProviderField <SqlDataReader, SqlDouble, SqlDouble>((r, i) => r.GetSqlDouble(i));
                SetProviderField <SqlDataReader, SqlGuid, SqlGuid>((r, i) => r.GetSqlGuid(i));
                SetProviderField <SqlDataReader, SqlInt16, SqlInt16>((r, i) => r.GetSqlInt16(i));
                SetProviderField <SqlDataReader, SqlInt32, SqlInt32>((r, i) => r.GetSqlInt32(i));
                SetProviderField <SqlDataReader, SqlInt64, SqlInt64>((r, i) => r.GetSqlInt64(i));
                SetProviderField <SqlDataReader, SqlMoney, SqlMoney>((r, i) => r.GetSqlMoney(i));
                SetProviderField <SqlDataReader, SqlSingle, SqlSingle>((r, i) => r.GetSqlSingle(i));
                SetProviderField <SqlDataReader, SqlString, SqlString>((r, i) => r.GetSqlString(i));
                SetProviderField <SqlDataReader, SqlXml, SqlXml>((r, i) => r.GetSqlXml(i));

                SetProviderField <SqlDataReader, DateTimeOffset>((r, i) => r.GetDateTimeOffset(i));
                SetProviderField <SqlDataReader, TimeSpan>      ((r, i) => r.GetTimeSpan(i));
            }
            else
            {
                SetProviderField <IDataReader, SqlString, SqlString>((r, i) => r.GetString(i));
            }

            _sqlOptimizer = new SqlServerSqlOptimizer(SqlProviderFlags);
            _sqlServer2000SqlOptimizer = new SqlServer2000SqlOptimizer(SqlProviderFlags);
            _sqlServer2005SqlOptimizer = new SqlServer2005SqlOptimizer(SqlProviderFlags);
        }