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";
|
csharpTypeName = "long";
|
||||||
if (csharpTypeName == "Boolean")
|
if (csharpTypeName == "Boolean")
|
||||||
csharpTypeName = "bool";
|
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";
|
return mappings.IsValuable() ? mappings.First().Key : "varchar";
|
||||||
}
|
}
|
||||||
public string GetCsharpTypeName(string dbTypeName)
|
public string GetCsharpTypeName(string dbTypeName)
|
||||||
@ -147,9 +147,15 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return "other";
|
return "other";
|
||||||
}
|
}
|
||||||
else if (dbTypeName == "xml") {
|
else if (dbTypeName == "xml")
|
||||||
|
{
|
||||||
return "string";
|
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)
|
else if (propertyTypes.First().Value == CSharpDataType.byteArray)
|
||||||
{
|
{
|
||||||
return "byte[]";
|
return "byte[]";
|
||||||
|
@ -20,7 +20,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
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
|
protected override string GetViewInfoListSql
|
||||||
@ -125,7 +125,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return "select 1 from Information_schema.columns limit 0,1";
|
return "select Name from sqlite_master limit 0,1";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -173,22 +173,22 @@ namespace SqlSugar
|
|||||||
}, (cm, key) =>
|
}, (cm, key) =>
|
||||||
{
|
{
|
||||||
List<DbColumnInfo> result = new List<DbColumnInfo>();
|
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)
|
foreach (DataRow row in schemaTable.Rows)
|
||||||
{
|
{
|
||||||
DbColumnInfo column = new DbColumnInfo()
|
DbColumnInfo column = new DbColumnInfo()
|
||||||
{
|
{
|
||||||
TableName = tableName,
|
TableName = tableName,
|
||||||
DataType = dr["DataTypeName"].ToString().Trim(),
|
DataType = row["DataTypeName"].ToString().Trim(),
|
||||||
IsNullable = (bool)dr["AllowDBNull"],
|
IsNullable = (bool)row["AllowDBNull"],
|
||||||
IsIdentity = (bool)dr["IsAutoIncrement"],
|
IsIdentity = (bool)row["IsAutoIncrement"],
|
||||||
ColumnDescription = null,
|
ColumnDescription = null,
|
||||||
DbColumnName = dr["ColumnName"].ToString(),
|
DbColumnName = row["ColumnName"].ToString(),
|
||||||
DefaultValue = dr["defultValue"].ToString(),
|
DefaultValue = row["defaultValue"].ToString(),
|
||||||
IsPrimarykey = (bool)dr["IsKey"],
|
IsPrimarykey = (bool)row["IsKey"],
|
||||||
Length = Convert.ToInt32(dr["ColumnSize"])
|
Length = Convert.ToInt32(row["ColumnSize"])
|
||||||
};
|
};
|
||||||
result.Add(column);
|
result.Add(column);
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
@ -12,28 +12,28 @@ namespace OrmTest.Demo
|
|||||||
{
|
{
|
||||||
var db = GetInstance();
|
var db = GetInstance();
|
||||||
//Create all class
|
//Create all class
|
||||||
db.DbFirst.CreateClassFile("c:\\DemoMySql\\1");
|
db.DbFirst.CreateClassFile("c:\\DemoSqlite\\1");
|
||||||
|
|
||||||
//Create student calsss
|
//Create student calsss
|
||||||
db.DbFirst.Where("Student").CreateClassFile("c:\\DemoMySql\\2");
|
db.DbFirst.Where("Student").CreateClassFile("c:\\DemoSqlite\\2");
|
||||||
//Where(array)
|
//Where(array)
|
||||||
|
|
||||||
//Mapping name
|
//Mapping name
|
||||||
db.MappingTables.Add("ClassStudent", "Student");
|
db.MappingTables.Add("ClassStudent", "Student");
|
||||||
db.MappingColumns.Add("NewId", "Id", "ClassStudent");
|
db.MappingColumns.Add("NewId", "Id", "ClassStudent");
|
||||||
db.DbFirst.Where("Student").CreateClassFile("c:\\DemoMySql\\3");
|
db.DbFirst.Where("Student").CreateClassFile("c:\\DemoSqlite\\3");
|
||||||
|
|
||||||
//Remove mapping
|
//Remove mapping
|
||||||
db.MappingTables.Clear();
|
db.MappingTables.Clear();
|
||||||
|
|
||||||
//Create class with default value
|
//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
|
//Mapping and Attribute
|
||||||
db.MappingTables.Add("ClassStudent", "Student");
|
db.MappingTables.Add("ClassStudent", "Student");
|
||||||
db.MappingColumns.Add("NewId", "Id", "ClassStudent");
|
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
|
//Remove mapping
|
||||||
@ -66,7 +66,7 @@ namespace OrmTest.Demo
|
|||||||
{
|
{
|
||||||
return old;
|
return old;
|
||||||
})
|
})
|
||||||
.CreateClassFile("c:\\DemoMySql\\6");
|
.CreateClassFile("c:\\DemoSqlite\\6");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,33 +17,33 @@ namespace OrmTest
|
|||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
//// /***Unit Test***/
|
////// /***Unit Test***/
|
||||||
new Field(1).Init();
|
//new Field(1).Init();
|
||||||
new Where(1).Init();
|
//new Where(1).Init();
|
||||||
new Method(1).Init();
|
//new Method(1).Init();
|
||||||
new JoinQuery(1).Init();
|
//new JoinQuery(1).Init();
|
||||||
new SingleQuery(1).Init();
|
//new SingleQuery(1).Init();
|
||||||
new SelectQuery(1).Init();
|
//new SelectQuery(1).Init();
|
||||||
new AutoClose(1).Init();
|
//new AutoClose(1).Init();
|
||||||
new Insert(1).Init();
|
//new Insert(1).Init();
|
||||||
new Delete(1).Init();
|
//new Delete(1).Init();
|
||||||
new Update(1).Init();
|
//new Update(1).Init();
|
||||||
new Mapping(1).Init();
|
//new Mapping(1).Init();
|
||||||
new DataTest(1).Init();
|
//new DataTest(1).Init();
|
||||||
|
|
||||||
// /***Performance Test***/
|
//// /***Performance Test***/
|
||||||
// new SqlSugarPerformance(100).Select();
|
//// new SqlSugarPerformance(100).Select();
|
||||||
|
|
||||||
/***Demo***/
|
///***Demo***/
|
||||||
OrmTest.Demo.Query.Init();
|
//OrmTest.Demo.Query.Init();
|
||||||
OrmTest.Demo.Insert.Init();
|
//OrmTest.Demo.Insert.Init();
|
||||||
OrmTest.Demo.Delete.Init();
|
//OrmTest.Demo.Delete.Init();
|
||||||
OrmTest.Demo.Update.Init();
|
//OrmTest.Demo.Update.Init();
|
||||||
OrmTest.Demo.DbFirst.Init();
|
OrmTest.Demo.DbFirst.Init();
|
||||||
OrmTest.Demo.JoinSql.Init();
|
//OrmTest.Demo.JoinSql.Init();
|
||||||
OrmTest.Demo.Filter.Init();
|
//OrmTest.Demo.Filter.Init();
|
||||||
OrmTest.Demo.ComplexModel.Init();
|
//OrmTest.Demo.ComplexModel.Init();
|
||||||
OrmTest.Demo.CodeFirst.Init();
|
//OrmTest.Demo.CodeFirst.Init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user