diff --git a/Src/Asp.Net/SqlSugar/Infrastructure/DependencyManagement.cs b/Src/Asp.Net/SqlSugar/Infrastructure/DependencyManagement.cs index 2f1ccf3cb..ac22fc1bd 100644 --- a/Src/Asp.Net/SqlSugar/Infrastructure/DependencyManagement.cs +++ b/Src/Asp.Net/SqlSugar/Infrastructure/DependencyManagement.cs @@ -50,6 +50,14 @@ namespace SqlSugar } } + internal static void TryPostgreSQL() + { + var message = ErrorMessage.GetThrowMessage( + "SqlSugar PostGreSQL only support.NET CORE", + "SqlSugar使用 PostGreSQL只支持.NET CORE"); + throw new Exception(message); + } + internal static void TryOracle() { if (!IsTryOracle) diff --git a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/CodeFirst/PostgreSQLCodeFirst.cs b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/CodeFirst/PostgreSQLCodeFirst.cs deleted file mode 100644 index 71051544b..000000000 --- a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/CodeFirst/PostgreSQLCodeFirst.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace SqlSugar -{ - public class PostgreSQLCodeFirst : CodeFirstProvider - { - public override void NoExistLogic(EntityInfo entityInfo) - { - var tableName = GetTableName(entityInfo); - Check.Exception(entityInfo.Columns.Where(it => it.IsPrimarykey).Count() > 1, "Use Code First ,The primary key must not exceed 1"); - List columns = new List(); - if (entityInfo.Columns.HasValue()) - { - foreach (var item in entityInfo.Columns) - { - DbColumnInfo dbColumnInfo = this.EntityColumnToDbColumn(entityInfo, tableName, item); - columns.Add(dbColumnInfo); - } - } - this.Context.DbMaintenance.CreateTable(tableName, columns); - } - protected override DbColumnInfo EntityColumnToDbColumn(EntityInfo entityInfo, string tableName, EntityColumnInfo item) - { - var result = new DbColumnInfo() - { - DataType = this.Context.Ado.DbBind.GetDbTypeName(UtilMethods.GetUnderType(item.PropertyInfo).Name), - TableId = entityInfo.Columns.IndexOf(item), - DbColumnName = item.DbColumnName.HasValue() ? item.DbColumnName : item.PropertyName, - IsPrimarykey = item.IsPrimarykey, - IsIdentity = item.IsIdentity, - TableName = tableName, - IsNullable = item.IsNullable, - DefaultValue = item.DefaultValue, - ColumnDescription = item.ColumnDescription, - Length = item.Length - }; - if (result.DataType.Equals("varchar", StringComparison.CurrentCultureIgnoreCase) && result.Length == 0) - { - result.Length = 1; - } - return result; - } - - protected override void ConvertColumns(List dbColumns) - { - foreach (var item in dbColumns) - { - if (item.DataType == "DateTime") - { - item.Length = 0; - } - } - } - - protected override void ChangeKey(EntityInfo entityInfo, string tableName, EntityColumnInfo item) - { - this.Context.DbMaintenance.UpdateColumn(tableName, EntityColumnToDbColumn(entityInfo, tableName, item)); - if (!item.IsPrimarykey) - this.Context.DbMaintenance.DropConstraint(tableName,null); - if (item.IsPrimarykey) - this.Context.DbMaintenance.AddPrimaryKey(tableName, item.DbColumnName); - } - } -} diff --git a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/DbBind/PostgreSQLDbBind.cs b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/DbBind/PostgreSQLDbBind.cs deleted file mode 100644 index 8068980cc..000000000 --- a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/DbBind/PostgreSQLDbBind.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace SqlSugar -{ - public class PostgreSQLDbBind : DbBindProvider - { - public override string GetDbTypeName(string csharpTypeName) - { - if (csharpTypeName == UtilConstants.ByteArrayType.Name) - { - return "blob"; - } - if (csharpTypeName == "Int32") - csharpTypeName = "int"; - if (csharpTypeName == "Int16") - csharpTypeName = "short"; - if (csharpTypeName == "Int64") - csharpTypeName = "long"; - if (csharpTypeName == "Boolean") - csharpTypeName = "bool"; - var mappings = this.MappingTypes.Where(it => it.Value.ToString().Equals(csharpTypeName, StringComparison.CurrentCultureIgnoreCase)); - return mappings.HasValue() ? mappings.First().Key : "varchar"; - } - public override List> MappingTypes - { - get - { - var extService = this.Context.CurrentConnectionConfig.ConfigureExternalServices; - if (extService != null && extService.AppendDataReaderTypeMappings.HasValue()) - { - return extService.AppendDataReaderTypeMappings.Union(MappingTypesConst).ToList(); - } - else - { - return MappingTypesConst; - } - } - } - public static List> MappingTypesConst = new List>(){ - - new KeyValuePair("int",CSharpDataType.@int), - new KeyValuePair("mediumint",CSharpDataType.@int), - new KeyValuePair("integer",CSharpDataType.@int), - - new KeyValuePair("varchar",CSharpDataType.@string), - new KeyValuePair("text",CSharpDataType.@string), - new KeyValuePair("char",CSharpDataType.@string), - new KeyValuePair("enum",CSharpDataType.@string), - new KeyValuePair("mediumtext",CSharpDataType.@string), - new KeyValuePair("tinytext",CSharpDataType.@string), - new KeyValuePair("longtext",CSharpDataType.@string), - - new KeyValuePair("tinyint",CSharpDataType.@byte), - new KeyValuePair("smallint",CSharpDataType.@short), - new KeyValuePair("bigint",CSharpDataType.@long), - new KeyValuePair("bit",CSharpDataType.@bool), - new KeyValuePair("real",CSharpDataType.@double), - new KeyValuePair("double",CSharpDataType.@double), - new KeyValuePair("float",CSharpDataType.@float), - new KeyValuePair("float",CSharpDataType.Single), - new KeyValuePair("decimal",CSharpDataType.@decimal), - new KeyValuePair("numeric",CSharpDataType.@decimal), - new KeyValuePair("year",CSharpDataType.@int), - - new KeyValuePair("datetime",CSharpDataType.DateTime), - new KeyValuePair("timestamp",CSharpDataType.DateTime), - new KeyValuePair("date",CSharpDataType.DateTime), - new KeyValuePair("time",CSharpDataType.DateTime), - - new KeyValuePair("blob",CSharpDataType.byteArray), - new KeyValuePair("tinyblob",CSharpDataType.byteArray), - new KeyValuePair("varbinary",CSharpDataType.byteArray), - new KeyValuePair("binary",CSharpDataType.byteArray), - new KeyValuePair("multipoint",CSharpDataType.byteArray), - new KeyValuePair("geometry",CSharpDataType.byteArray), - new KeyValuePair("multilinestring",CSharpDataType.byteArray), - new KeyValuePair("polygon",CSharpDataType.byteArray), - new KeyValuePair("mediumblob",CSharpDataType.byteArray), - - new KeyValuePair("varchar",CSharpDataType.Guid), - }; - public override List StringThrow - { - get - { - return new List() { "int32", "datetime", "decimal", "double", "byte" }; - } - } - } -} diff --git a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/DbFirst/PostgreSQLDbFirst.cs b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/DbFirst/PostgreSQLDbFirst.cs deleted file mode 100644 index fe829d0b3..000000000 --- a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/DbFirst/PostgreSQLDbFirst.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace SqlSugar -{ - public class PostgreSQLDbFirst : DbFirstProvider - { - } -} diff --git a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/PostgreSQLProvider.cs b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/PostgreSQLProvider.cs deleted file mode 100644 index 5bfc2d375..000000000 --- a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/PostgreSQLProvider.cs +++ /dev/null @@ -1,116 +0,0 @@ -using MySql.Data.MySqlClient; -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.SqlClient; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace SqlSugar -{ - public class PostgreSQLProvider : AdoProvider - { - public PostgreSQLProvider() { } - public override IDbConnection Connection - { - get - { - if (base._DbConnection == null) - { - try - { - var mySqlConnectionString = base.Context.CurrentConnectionConfig.ConnectionString; - if (!mySqlConnectionString.ToLower().Contains("charset")) - { - mySqlConnectionString = mySqlConnectionString.Trim().TrimEnd(';') + ";charset=utf8;"; - } - base._DbConnection = new MySqlConnection(mySqlConnectionString); - } - catch (Exception ex) - { - Check.Exception(true, ErrorMessage.ConnnectionOpen, ex.Message); - } - } - return base._DbConnection; - } - set - { - base._DbConnection = value; - } - } - - public override void BeginTran(string transactionName) - { - base.BeginTran(); - } - /// - /// Only SqlServer - /// - /// - /// - public override void BeginTran(IsolationLevel iso, string transactionName) - { - base.BeginTran(iso); - } - public override IDataAdapter GetAdapter() - { - return new MySqlDataAdapter(); - } - public override IDbCommand GetCommand(string sql, SugarParameter[] parameters) - { - MySqlCommand sqlCommand = new MySqlCommand(sql, (MySqlConnection)this.Connection); - sqlCommand.CommandType = this.CommandType; - sqlCommand.CommandTimeout = this.CommandTimeOut; - if (this.Transaction != null) - { - sqlCommand.Transaction = (MySqlTransaction)this.Transaction; - } - if (parameters.HasValue()) - { - IDataParameter[] ipars = ToIDbDataParameter(parameters); - sqlCommand.Parameters.AddRange((MySqlParameter[])ipars); - } - CheckConnection(); - return sqlCommand; - } - public override void SetCommandToAdapter(IDataAdapter dataAdapter, IDbCommand command) - { - ((MySqlDataAdapter)dataAdapter).SelectCommand = (MySqlCommand)command; - } - /// - /// if mysql return MySqlParameter[] pars - /// if sqlerver return SqlParameter[] pars ... - /// - /// - /// - public override IDataParameter[] ToIDbDataParameter(params SugarParameter[] parameters) - { - if (parameters == null || parameters.Length == 0) return null; - MySqlParameter[] result = new MySqlParameter[parameters.Length]; - int index = 0; - foreach (var parameter in parameters) - { - if (parameter.Value == null) parameter.Value = DBNull.Value; - var sqlParameter = new MySqlParameter(); - sqlParameter.ParameterName = parameter.ParameterName; - sqlParameter.Size = parameter.Size; - sqlParameter.Value = parameter.Value; - sqlParameter.DbType = parameter.DbType; - sqlParameter.Direction = parameter.Direction; - if (sqlParameter.Direction == 0) - { - sqlParameter.Direction = ParameterDirection.Input; - } - result[index] = sqlParameter; - if (sqlParameter.Direction.IsIn(ParameterDirection.Output, ParameterDirection.InputOutput)) - { - if (this.OutputParameters == null) this.OutputParameters = new List(); - this.OutputParameters.RemoveAll(it => it.ParameterName == sqlParameter.ParameterName); - this.OutputParameters.Add(sqlParameter); - } - ++index; - } - return result; - } - } -} diff --git a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/Queryable/PostgreSQLQueryable.cs b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/Queryable/PostgreSQLQueryable.cs deleted file mode 100644 index c8bc5d9f6..000000000 --- a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/Queryable/PostgreSQLQueryable.cs +++ /dev/null @@ -1,60 +0,0 @@ -namespace SqlSugar -{ - public class PostgreSQLProviderQueryable : QueryableProvider - { - public override ISugarQueryable With(string withString) - { - return this; - } - - public override ISugarQueryable PartitionBy(string groupFileds) - { - this.GroupBy(groupFileds); - return this; - } - } - public class PostgreSQLQueryable : QueryableProvider - { - - } - public class PostgreSQLQueryable : QueryableProvider - { - - } - public class PostgreSQLQueryable : QueryableProvider - { - - } - public class PostgreSQLQueryable : QueryableProvider - { - - } - public class PostgreSQLQueryable : QueryableProvider - { - - } - public class PostgreSQLQueryable : QueryableProvider - { - - } - public class PostgreSQLQueryable : QueryableProvider - { - - } - public class PostgreSQLQueryable : QueryableProvider - { - - } - public class PostgreSQLQueryable : QueryableProvider - { - - } - public class PostgreSQLQueryable : QueryableProvider - { - - } - public class PostgreSQLQueryable : QueryableProvider - { - - } -} diff --git a/Src/Asp.Net/SqlSugar/SqlSugar.csproj b/Src/Asp.Net/SqlSugar/SqlSugar.csproj index 7bf6918df..4fc75d517 100644 --- a/Src/Asp.Net/SqlSugar/SqlSugar.csproj +++ b/Src/Asp.Net/SqlSugar/SqlSugar.csproj @@ -110,11 +110,6 @@ - - - - - @@ -274,10 +269,7 @@ - - - - +