mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 13:34:32 +08:00
Update Sqlite
This commit is contained in:
parent
a50972b8db
commit
d23dae5229
@ -29,7 +29,7 @@ namespace SqlSugar
|
||||
csharpTypeName = "long";
|
||||
if (csharpTypeName == "Boolean")
|
||||
csharpTypeName = "bool";
|
||||
var mappings = this.MappingTypes.Where(it => it.Value.ToString().Equals(csharpTypeName,StringComparison.CurrentCultureIgnoreCase));
|
||||
var mappings = this.MappingTypes.Where(it => it.Value.ToString().Equals(csharpTypeName, StringComparison.CurrentCultureIgnoreCase));
|
||||
return mappings.IsValuable() ? mappings.First().Key : "varchar";
|
||||
}
|
||||
public string GetCsharpTypeName(string dbTypeName)
|
||||
@ -147,9 +147,15 @@ namespace SqlSugar
|
||||
{
|
||||
return "other";
|
||||
}
|
||||
else if (dbTypeName == "xml") {
|
||||
else if (dbTypeName == "xml")
|
||||
{
|
||||
return "string";
|
||||
}
|
||||
else if (propertyTypes == null || propertyTypes.Count() == 0)
|
||||
{
|
||||
Check.ThrowNotSupportedException(string.Format(" \"{0}\" Type NotSupported, DbBindProvider.GetPropertyTypeName error.", dbTypeName));
|
||||
return null;
|
||||
}
|
||||
else if (propertyTypes.First().Value == CSharpDataType.byteArray)
|
||||
{
|
||||
return "byte[]";
|
||||
|
@ -20,7 +20,7 @@ namespace SqlSugar
|
||||
{
|
||||
get
|
||||
{
|
||||
return @"select Name from sqlite_master where type='table' order by name;";
|
||||
return @"select Name from sqlite_master where type='table' and name<>'sqlite_sequence' order by name;";
|
||||
}
|
||||
}
|
||||
protected override string GetViewInfoListSql
|
||||
@ -125,7 +125,7 @@ namespace SqlSugar
|
||||
{
|
||||
get
|
||||
{
|
||||
return "select 1 from Information_schema.columns limit 0,1";
|
||||
return "select Name from sqlite_master limit 0,1";
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@ -173,22 +173,22 @@ namespace SqlSugar
|
||||
}, (cm, key) =>
|
||||
{
|
||||
List<DbColumnInfo> result = new List<DbColumnInfo>();
|
||||
using (var dr = this.Context.Ado.GetDataReader("select * from " + tableName + " limit 0,1"))
|
||||
using (var dataReader = this.Context.Ado.GetDataReader("select * from " + tableName + " limit 0,1"))
|
||||
{
|
||||
var schemaTable = dr.GetSchemaTable();
|
||||
var schemaTable = dataReader.GetSchemaTable();
|
||||
foreach (DataRow row in schemaTable.Rows)
|
||||
{
|
||||
DbColumnInfo column = new DbColumnInfo()
|
||||
{
|
||||
TableName = tableName,
|
||||
DataType = dr["DataTypeName"].ToString().Trim(),
|
||||
IsNullable = (bool)dr["AllowDBNull"],
|
||||
IsIdentity = (bool)dr["IsAutoIncrement"],
|
||||
DataType = row["DataTypeName"].ToString().Trim(),
|
||||
IsNullable = (bool)row["AllowDBNull"],
|
||||
IsIdentity = (bool)row["IsAutoIncrement"],
|
||||
ColumnDescription = null,
|
||||
DbColumnName = dr["ColumnName"].ToString(),
|
||||
DefaultValue = dr["defultValue"].ToString(),
|
||||
IsPrimarykey = (bool)dr["IsKey"],
|
||||
Length = Convert.ToInt32(dr["ColumnSize"])
|
||||
DbColumnName = row["ColumnName"].ToString(),
|
||||
DefaultValue = row["defaultValue"].ToString(),
|
||||
IsPrimarykey = (bool)row["IsKey"],
|
||||
Length = Convert.ToInt32(row["ColumnSize"])
|
||||
};
|
||||
result.Add(column);
|
||||
}
|
||||
|
Binary file not shown.
@ -12,28 +12,28 @@ namespace OrmTest.Demo
|
||||
{
|
||||
var db = GetInstance();
|
||||
//Create all class
|
||||
db.DbFirst.CreateClassFile("c:\\DemoMySql\\1");
|
||||
db.DbFirst.CreateClassFile("c:\\DemoSqlite\\1");
|
||||
|
||||
//Create student calsss
|
||||
db.DbFirst.Where("Student").CreateClassFile("c:\\DemoMySql\\2");
|
||||
db.DbFirst.Where("Student").CreateClassFile("c:\\DemoSqlite\\2");
|
||||
//Where(array)
|
||||
|
||||
//Mapping name
|
||||
db.MappingTables.Add("ClassStudent", "Student");
|
||||
db.MappingColumns.Add("NewId", "Id", "ClassStudent");
|
||||
db.DbFirst.Where("Student").CreateClassFile("c:\\DemoMySql\\3");
|
||||
db.DbFirst.Where("Student").CreateClassFile("c:\\DemoSqlite\\3");
|
||||
|
||||
//Remove mapping
|
||||
db.MappingTables.Clear();
|
||||
|
||||
//Create class with default value
|
||||
db.DbFirst.IsCreateDefaultValue().CreateClassFile("c:\\DemoMySql\\4", "Demo.Models");
|
||||
db.DbFirst.IsCreateDefaultValue().CreateClassFile("c:\\DemoSqlite\\4", "Demo.Models");
|
||||
|
||||
|
||||
//Mapping and Attribute
|
||||
db.MappingTables.Add("ClassStudent", "Student");
|
||||
db.MappingColumns.Add("NewId", "Id", "ClassStudent");
|
||||
db.DbFirst.IsCreateAttribute().Where("Student").CreateClassFile("c:\\DemoMySql\\5");
|
||||
db.DbFirst.IsCreateAttribute().Where("Student").CreateClassFile("c:\\DemoSqlite\\5");
|
||||
|
||||
|
||||
//Remove mapping
|
||||
@ -66,7 +66,7 @@ namespace OrmTest.Demo
|
||||
{
|
||||
return old;
|
||||
})
|
||||
.CreateClassFile("c:\\DemoMySql\\6");
|
||||
.CreateClassFile("c:\\DemoSqlite\\6");
|
||||
}
|
||||
}
|
||||
}
|
@ -17,33 +17,33 @@ namespace OrmTest
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
//// /***Unit Test***/
|
||||
new Field(1).Init();
|
||||
new Where(1).Init();
|
||||
new Method(1).Init();
|
||||
new JoinQuery(1).Init();
|
||||
new SingleQuery(1).Init();
|
||||
new SelectQuery(1).Init();
|
||||
new AutoClose(1).Init();
|
||||
new Insert(1).Init();
|
||||
new Delete(1).Init();
|
||||
new Update(1).Init();
|
||||
new Mapping(1).Init();
|
||||
new DataTest(1).Init();
|
||||
////// /***Unit Test***/
|
||||
//new Field(1).Init();
|
||||
//new Where(1).Init();
|
||||
//new Method(1).Init();
|
||||
//new JoinQuery(1).Init();
|
||||
//new SingleQuery(1).Init();
|
||||
//new SelectQuery(1).Init();
|
||||
//new AutoClose(1).Init();
|
||||
//new Insert(1).Init();
|
||||
//new Delete(1).Init();
|
||||
//new Update(1).Init();
|
||||
//new Mapping(1).Init();
|
||||
//new DataTest(1).Init();
|
||||
|
||||
// /***Performance Test***/
|
||||
// new SqlSugarPerformance(100).Select();
|
||||
//// /***Performance Test***/
|
||||
//// new SqlSugarPerformance(100).Select();
|
||||
|
||||
/***Demo***/
|
||||
OrmTest.Demo.Query.Init();
|
||||
OrmTest.Demo.Insert.Init();
|
||||
OrmTest.Demo.Delete.Init();
|
||||
OrmTest.Demo.Update.Init();
|
||||
///***Demo***/
|
||||
//OrmTest.Demo.Query.Init();
|
||||
//OrmTest.Demo.Insert.Init();
|
||||
//OrmTest.Demo.Delete.Init();
|
||||
//OrmTest.Demo.Update.Init();
|
||||
OrmTest.Demo.DbFirst.Init();
|
||||
OrmTest.Demo.JoinSql.Init();
|
||||
OrmTest.Demo.Filter.Init();
|
||||
OrmTest.Demo.ComplexModel.Init();
|
||||
OrmTest.Demo.CodeFirst.Init();
|
||||
//OrmTest.Demo.JoinSql.Init();
|
||||
//OrmTest.Demo.Filter.Init();
|
||||
//OrmTest.Demo.ComplexModel.Init();
|
||||
//OrmTest.Demo.CodeFirst.Init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user