Browse Source

-

pull/12/MERGE
sunkaixuan 8 years ago
parent
commit
2fa8f455a6
  1. 15
      SqlServerTest/Demo/DbFirst.cs
  2. 14
      SqlServerTest/Demo/Delete.cs
  3. 23
      SqlServerTest/Demo/DemoBase.cs
  4. 17
      SqlServerTest/Demo/Insert.cs
  5. 15
      SqlServerTest/Demo/Query.cs
  6. 16
      SqlServerTest/Demo/Update.cs
  7. 2
      SqlServerTest/SqlServerTest.csproj
  8. 13
      SqlSugar/Abstract/DbFirstProvider/DbFirstProvider.cs

15
SqlServerTest/Demo/DbFirst.cs

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OrmTest.Demo
{
public class DbFirst
{
public static void Init()
{
}
}
}

14
SqlServerTest/Demo/Delete.cs

@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace OrmTest.Demo
{
public class Delete
public class Delete:DemoBase
{
public static void Init()
{
@ -29,17 +29,5 @@ namespace OrmTest.Demo
//by expression
var t5 = db.Deleteable<Student>().Where(it => it.Id == 1).ExecuteCommand();
}
public static SqlSugarClient GetInstance()
{
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true });
db.Ado.IsEnableLogEvent = true;
db.Ado.LogEventStarting = (sql, pars) =>
{
Console.WriteLine(sql + "\r\n" + db.RewritableMethods.SerializeObject(pars));
Console.WriteLine();
};
return db;
}
}
}

23
SqlServerTest/Demo/DemoBase.cs

@ -0,0 +1,23 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OrmTest.Demo
{
public class DemoBase
{
public static SqlSugarClient GetInstance()
{
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true });
db.Ado.IsEnableLogEvent = true;
db.Ado.LogEventStarting = (sql, pars) =>
{
Console.WriteLine(sql + "\r\n" + db.RewritableMethods.SerializeObject(pars));
Console.WriteLine();
};
return db;
}
}
}

17
SqlServerTest/Demo/Insert.cs

@ -8,9 +8,10 @@ using System.Threading.Tasks;
namespace OrmTest.Demo
{
public class Insert
public class Insert:DemoBase
{
public static void Init()
{
public static void Init() {
var db = GetInstance();
db.IgnoreColumns.Add("TestId", "Student");
@ -50,17 +51,5 @@ namespace OrmTest.Demo
}
var s9 = db.Insertable(insertObjs.ToArray()).InsertColumns(it => new { it.Name }).ExecuteCommand();
}
public static SqlSugarClient GetInstance()
{
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true });
db.Ado.IsEnableLogEvent = true;
db.Ado.LogEventStarting = (sql, pars) =>
{
Console.WriteLine(sql + "\r\n" + db.RewritableMethods.SerializeObject(pars));
Console.WriteLine();
};
return db;
}
}
}

15
SqlServerTest/Demo/Query.cs

@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace OrmTest.Demo
{
public class Query
public class Query:DemoBase
{
public static void Init()
@ -273,18 +273,5 @@ namespace OrmTest.Demo
.Select("st.*").ToList();
//SELECT st.* FROM [Student] st Left JOIN School sh ON sh.id=st.schoolid WHERE st.id>@id
}
public static SqlSugarClient GetInstance()
{
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig{ ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true });
db.Ado.IsEnableLogEvent = true;
db.Ado.LogEventStarting = (sql, pars) =>
{
Console.WriteLine(sql + "\r\n" + db.RewritableMethods.SerializeObject(pars));
Console.WriteLine();
};
return db;
}
}
}

16
SqlServerTest/Demo/Update.cs

@ -8,9 +8,10 @@ using System.Threading.Tasks;
namespace OrmTest.Demo
{
public class Update
public class Update : DemoBase
{
public static void Init()
{
public static void Init() {
var db = GetInstance();
var updateObj = new Student() { Id = 1, Name = "jack", SchoolId = 0, CreateTime = Convert.ToDateTime("2017-05-21 09:56:12.610") };
var updateObjs = new List<Student>() { updateObj, new Student() { Id = 2, Name = "sun", SchoolId = 0 } }.ToArray();
@ -54,16 +55,5 @@ namespace OrmTest.Demo
db.Updateable<School>().AS("Student").UpdateColumns(it => new School() { Name = "jack" }).Where(it => it.Id == 1).ExecuteCommand();
//Update Student set Name='jack' Where Id=1
}
public static SqlSugarClient GetInstance()
{
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true });
db.Ado.IsEnableLogEvent = true;
db.Ado.LogEventStarting = (sql, pars) =>
{
Console.WriteLine(sql + "\r\n" + db.RewritableMethods.SerializeObject(pars));
Console.WriteLine();
};
return db;
}
}
}

2
SqlServerTest/SqlServerTest.csproj

@ -48,7 +48,9 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Config.cs" />
<Compile Include="Demo\DbFirst.cs" />
<Compile Include="Demo\Delete.cs" />
<Compile Include="Demo\DemoBase.cs" />
<Compile Include="Demo\Insert.cs" />
<Compile Include="Demo\Query.cs" />
<Compile Include="Demo\Update.cs" />

13
SqlSugar/Abstract/DbFirstProvider/DbFirstProvider.cs

@ -119,6 +119,13 @@ namespace SqlSugar
public Dictionary<string, string> ToClassStringList(string nameSpace = "Models")
{
Dictionary<string, string> result = new Dictionary<string, string>();
if (this.TableInfoList.IsValuable())
{
foreach (var tableInfo in this.TableInfoList)
{
}
}
this.Namespace = nameSpace;
return result;
}
@ -132,9 +139,11 @@ namespace SqlSugar
foreach (var item in classStringList)
{
string className = item.Key;
if (this.Context.MappingTables.IsValuable()) {
if (this.Context.MappingTables.IsValuable())
{
var mappingInfo = this.Context.MappingTables.FirstOrDefault(it => it.DbTableName.Equals(item.Key, StringComparison.CurrentCultureIgnoreCase));
if (mappingInfo.IsValuable()) {
if (mappingInfo.IsValuable())
{
className = mappingInfo.EntityName;
}
}

Loading…
Cancel
Save