diff --git a/RepoDb.SqlServer/RepoDb.SqlServer.IntegrationTests/AttributeTest.cs b/RepoDb.SqlServer/RepoDb.SqlServer.IntegrationTests/AttributeTest.cs index 030a702ab..f687113c5 100644 --- a/RepoDb.SqlServer/RepoDb.SqlServer.IntegrationTests/AttributeTest.cs +++ b/RepoDb.SqlServer/RepoDb.SqlServer.IntegrationTests/AttributeTest.cs @@ -1,6 +1,6 @@ using Microsoft.Data.SqlClient; using Microsoft.VisualStudio.TestTools.UnitTesting; -using RepoDb.Attributes; +using RepoDb.Attributes.Parameter.SqlServer; using RepoDb.Extensions; using RepoDb.SqlServer.IntegrationTests.Setup; using System; @@ -35,40 +35,19 @@ public class MdsAttributeTable { public int Id { get; set; } - [MicrosoftSqlServerTypeMap(SqlDbType.UniqueIdentifier)] + [SqlDbType(SqlDbType.UniqueIdentifier)] public Guid SessionId { get; set; } - [MicrosoftSqlServerTypeMap(SqlDbType.Binary)] + [SqlDbType(SqlDbType.Binary)] public byte[] ColumnBinary { get; set; } - [MicrosoftSqlServerTypeMap(SqlDbType.BigInt)] + [SqlDbType(SqlDbType.BigInt)] public long ColumnBigInt { get; set; } - [MicrosoftSqlServerTypeMap(SqlDbType.DateTime2)] + [SqlDbType(SqlDbType.DateTime2)] public DateTime ColumnDateTime2 { get; set; } - [MicrosoftSqlServerTypeMap(SqlDbType.Text)] - public string ColumnNVarChar { get; set; } - } - - [Table("CompleteTable")] - public class SdsAttributeTable - { - public int Id { get; set; } - - [SystemSqlServerTypeMap(SqlDbType.UniqueIdentifier)] - public Guid SessionId { get; set; } - - [SystemSqlServerTypeMap(SqlDbType.Binary)] - public byte[] ColumnBinary { get; set; } - - [SystemSqlServerTypeMap(SqlDbType.BigInt)] - public long ColumnBigInt { get; set; } - - [SystemSqlServerTypeMap(SqlDbType.DateTime2)] - public DateTime ColumnDateTime2 { get; set; } - - [SystemSqlServerTypeMap(SqlDbType.Text)] + [SqlDbType(SqlDbType.Text)] public string ColumnNVarChar { get; set; } } @@ -93,23 +72,6 @@ private IEnumerable CreateMdsAttributeTables(int count = 10) } } - private IEnumerable CreateSdsAttributeTables(int count = 10) - { - var random = new Random(); - for (var i = 0; i < count; i++) - { - yield return new SdsAttributeTable - { - Id = i, - ColumnBigInt = Convert.ToInt64(random.Next(int.MaxValue)), - ColumnBinary = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString()), - ColumnDateTime2 = DateTime.UtcNow.AddDays(-random.Next(100)), - ColumnNVarChar = $"ColumnNVarChar-{i}-{Guid.NewGuid()}", - SessionId = Guid.NewGuid() - }; - } - } - #endregion #region MDS @@ -197,91 +159,5 @@ public void TestSqlConnectionForQueryAllForMicrosoftSqlServerTypeMapAttribute() } #endregion - - #region SDS - - [TestMethod] - public void TestSqlConnectionForInsertForSystemSqlServerTypeMapAttribute() - { - // Setup - var table = CreateSdsAttributeTables(1).First(); - - using (var connection = new System.Data.SqlClient.SqlConnection(Database.ConnectionString)) - { - // Act - connection.Insert(table); - - // Assert - Assert.AreEqual(1, connection.CountAll()); - - // Query - var queryResult = connection.QueryAll().First(); - - // Assert - Helper.AssertPropertiesEquality(table, queryResult); - } - } - - [TestMethod] - public void TestSqlConnectionForInsertAllForSystemSqlServerTypeMapAttribute() - { - // Setup - var tables = CreateSdsAttributeTables(10).AsList(); - - using (var connection = new System.Data.SqlClient.SqlConnection(Database.ConnectionString)) - { - // Act - connection.InsertAll(tables); - - // Assert - Assert.AreEqual(tables.Count, connection.CountAll()); - - // Query - var queryResult = connection.QueryAll(); - - // Assert - tables.ForEach(table => Helper.AssertPropertiesEquality(table, queryResult.First(e => e.Id == table.Id))); - } - } - - [TestMethod] - public void TestSqlConnectionForQueryForSystemSqlServerTypeMapAttribute() - { - // Setup - var table = CreateSdsAttributeTables(1).First(); - - using (var connection = new System.Data.SqlClient.SqlConnection(Database.ConnectionString)) - { - // Act - var id = connection.Insert(table); - - // Query - var queryResult = connection.Query(id).First(); - - // Assert - Helper.AssertPropertiesEquality(table, queryResult); - } - } - - [TestMethod] - public void TestSqlConnectionForQueryAllForSystemSqlServerTypeMapAttribute() - { - // Setup - var tables = CreateSdsAttributeTables(10).AsList(); - - using (var connection = new System.Data.SqlClient.SqlConnection(Database.ConnectionString)) - { - // Act - connection.InsertAll(tables); - - // Query - var queryResult = connection.QueryAll(); - - // Assert - Assert.AreEqual(tables.Count, queryResult.Count()); - } - } - - #endregion } } diff --git a/RepoDb.SqlServer/RepoDb.SqlServer.IntegrationTests/MaxSizesTest.cs b/RepoDb.SqlServer/RepoDb.SqlServer.IntegrationTests/MaxSizesTest.cs index 5feaf3d76..904b0b79c 100644 --- a/RepoDb.SqlServer/RepoDb.SqlServer.IntegrationTests/MaxSizesTest.cs +++ b/RepoDb.SqlServer/RepoDb.SqlServer.IntegrationTests/MaxSizesTest.cs @@ -1,10 +1,10 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.Data.SqlClient; +using Microsoft.VisualStudio.TestTools.UnitTesting; using RepoDb.Attributes; using RepoDb.Extensions; using RepoDb.SqlServer.IntegrationTests.Setup; using System; using System.Collections.Generic; -using System.Data.SqlClient; using System.Linq; using System.Text; diff --git a/RepoDb.SqlServer/RepoDb.SqlServer/Attributes/MicrosoftSqlServerTypeMapAttribute.cs b/RepoDb.SqlServer/RepoDb.SqlServer/Attributes/MicrosoftSqlServerTypeMapAttribute.cs deleted file mode 100644 index 39b9492a8..000000000 --- a/RepoDb.SqlServer/RepoDb.SqlServer/Attributes/MicrosoftSqlServerTypeMapAttribute.cs +++ /dev/null @@ -1,26 +0,0 @@ -using RepoDb.Attributes.Parameter.SqlServer; -using System; -using System.Data; - -namespace RepoDb.Attributes -{ - /// - /// An attribute used to define a mapping of .NET CLR into its equivalent value. - /// - [Obsolete("Use the RepoDb.Attributes.SqlServer.SqlDbTypeAttribute instead.")] - public class MicrosoftSqlServerTypeMapAttribute : SqlDbTypeAttribute - { - /// - /// Creates a new instance of class. - /// - /// The value of the target . - public MicrosoftSqlServerTypeMapAttribute(SqlDbType sqlDbType) - : base(sqlDbType) - { } - - /// - /// Gets the mapped value of the property. - /// - public SqlDbType DbType => (SqlDbType)Value; - } -} \ No newline at end of file diff --git a/RepoDb.SqlServer/RepoDb.SqlServer/Attributes/SystemSqlServerTypeMapAttribute.cs b/RepoDb.SqlServer/RepoDb.SqlServer/Attributes/SystemSqlServerTypeMapAttribute.cs deleted file mode 100644 index 29a6241d9..000000000 --- a/RepoDb.SqlServer/RepoDb.SqlServer/Attributes/SystemSqlServerTypeMapAttribute.cs +++ /dev/null @@ -1,27 +0,0 @@ -using RepoDb.Attributes.Parameter; -using System; -using System.Data; -using System.Data.SqlClient; - -namespace RepoDb.Attributes -{ - /// - /// An attribute used to define a mapping of .NET CLR into its equivalent value. - /// - [Obsolete("Use the RepoDb.Attributes.SqlServer.SqlDbTypeAttribute instead. The System.Data.SqlClient namespace support will soon be removed from the library.")] - public class SystemSqlServerTypeMapAttribute : PropertyValueAttribute - { - /// - /// Creates a new instance of class. - /// - /// A target value. - public SystemSqlServerTypeMapAttribute(SqlDbType dbType) - : base(typeof(SqlParameter), nameof(SqlParameter.SqlDbType), dbType) - { } - - /// - /// Gets a that is currently mapped. - /// - public SqlDbType DbType => (SqlDbType)Value; - } -} \ No newline at end of file diff --git a/RepoDb.SqlServer/RepoDb.SqlServer/RepoDb.SqlServer.csproj b/RepoDb.SqlServer/RepoDb.SqlServer/RepoDb.SqlServer.csproj index c0eabe5ab..cd63114ed 100644 --- a/RepoDb.SqlServer/RepoDb.SqlServer/RepoDb.SqlServer.csproj +++ b/RepoDb.SqlServer/RepoDb.SqlServer/RepoDb.SqlServer.csproj @@ -17,7 +17,6 @@ - diff --git a/RepoDb.SqlServer/RepoDb.SqlServer/SqlServerBootstrap.cs b/RepoDb.SqlServer/RepoDb.SqlServer/SqlServerBootstrap.cs index e3ea9701b..5df05434b 100644 --- a/RepoDb.SqlServer/RepoDb.SqlServer/SqlServerBootstrap.cs +++ b/RepoDb.SqlServer/RepoDb.SqlServer/SqlServerBootstrap.cs @@ -1,11 +1,12 @@ -using RepoDb.DbHelpers; +using Microsoft.Data.SqlClient; +using RepoDb.DbHelpers; using RepoDb.DbSettings; using RepoDb.StatementBuilders; namespace RepoDb { /// - /// A class that is used to initialize the necessary settings for both the and objects. + /// A class that is being used to initialize the necessary settings for the object. /// public static class SqlServerBootstrap { @@ -21,7 +22,7 @@ public static class SqlServerBootstrap #region Methods /// - /// Initializes all necessary settings for SqlServer. + /// Initializes all the necessary settings for SQL Server. /// public static void Initialize() { @@ -33,18 +34,15 @@ public static void Initialize() // Map the DbSetting var dbSetting = new SqlServerDbSetting(); - DbSettingMapper.Add(dbSetting, true); - DbSettingMapper.Add(dbSetting, true); + DbSettingMapper.Add(dbSetting, true); // Map the DbHelper var dbHelper = new SqlServerDbHelper(); - DbHelperMapper.Add(dbHelper, true); - DbHelperMapper.Add(dbHelper, true); + DbHelperMapper.Add(dbHelper, true); // Map the Statement Builder var statementBuilder = new SqlServerStatementBuilder(dbSetting); - StatementBuilderMapper.Add(statementBuilder, true); - StatementBuilderMapper.Add(statementBuilder, true); + StatementBuilderMapper.Add(statementBuilder, true); // Set the flag IsInitialized = true;