using System; using System.Collections.Generic; using System.Linq; namespace SqlSugar { public class SqliteDbBind : 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("integer",CSharpDataType.@int), new KeyValuePair("int",CSharpDataType.@int), new KeyValuePair("int32",CSharpDataType.@int), new KeyValuePair("integer32",CSharpDataType.@int), new KeyValuePair("number",CSharpDataType.@int), new KeyValuePair("varchar",CSharpDataType.@string), new KeyValuePair("varchar2",CSharpDataType.@string), new KeyValuePair("nvarchar",CSharpDataType.@string), new KeyValuePair("nvarchar2",CSharpDataType.@string), new KeyValuePair("text",CSharpDataType.@string), new KeyValuePair("ntext",CSharpDataType.@string), new KeyValuePair("blob_text",CSharpDataType.@string), new KeyValuePair("char",CSharpDataType.@string), new KeyValuePair("nchar",CSharpDataType.@string), new KeyValuePair("num",CSharpDataType.@string), new KeyValuePair("currency",CSharpDataType.@string), new KeyValuePair("datetext",CSharpDataType.@string), new KeyValuePair("word",CSharpDataType.@string), new KeyValuePair("graphic",CSharpDataType.@string), new KeyValuePair("tinyint",CSharpDataType.@byte), new KeyValuePair("unsignedinteger8",CSharpDataType.@byte), new KeyValuePair("smallint",CSharpDataType.@short), new KeyValuePair("int16",CSharpDataType.@short), new KeyValuePair("bigint",CSharpDataType.@long), new KeyValuePair("int64",CSharpDataType.@long), new KeyValuePair("long",CSharpDataType.@long), new KeyValuePair("integer64",CSharpDataType.@long), new KeyValuePair("bit",CSharpDataType.@bool), new KeyValuePair("bool",CSharpDataType.@bool), new KeyValuePair("boolean",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("dec",CSharpDataType.@decimal), new KeyValuePair("numeric",CSharpDataType.@decimal), new KeyValuePair("money",CSharpDataType.@decimal), new KeyValuePair("smallmoney",CSharpDataType.@decimal), 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("clob",CSharpDataType.byteArray), new KeyValuePair("raw",CSharpDataType.byteArray), new KeyValuePair("oleobject",CSharpDataType.byteArray), new KeyValuePair("binary",CSharpDataType.byteArray), new KeyValuePair("photo",CSharpDataType.byteArray), new KeyValuePair("picture",CSharpDataType.byteArray), new KeyValuePair("varchar",CSharpDataType.Guid), new KeyValuePair("guid",CSharpDataType.Guid) }; public override List StringThrow { get { return new List { "int32", "datetime", "decimal", "double", "byte"}; } } } }