-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
136 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using SmartSql.Bulk; | ||
using SmartSql.Bulk.MySql; | ||
using SmartSql.DataSource; | ||
using SmartSql.Test.Entities; | ||
using Xunit; | ||
|
||
namespace SmartSql.Test.Unit.Bulk | ||
{ | ||
public class MySqlTest | ||
{ | ||
[Fact] | ||
public void Insert() | ||
{ | ||
var dbSessionFactory = new SmartSqlBuilder() | ||
.UseDataSource(DbProvider.MYSQL, "Data Source=localhost;database=SmartSqlTestDB;uid=root;pwd=SmartSql.net") | ||
.Build().GetDbSessionFactory(); | ||
|
||
var list = new List<User> { | ||
new User {Id = 1, UserName = "1"} | ||
, new User {Id = 2, UserName = "2"} | ||
}; | ||
using (var dbSession = dbSessionFactory.Open()) | ||
{ | ||
var data = list.ToDataTable(); | ||
data.TableName = "t_user"; | ||
BulkInsert bulkInsert = new BulkInsert(dbSession) | ||
{ | ||
SecureFilePriv = "C:/ProgramData/MySQL/MySQL Server 8.0/Uploads", | ||
Table = data | ||
}; | ||
bulkInsert.Insert(); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using SmartSql.Bulk; | ||
using SmartSql.Bulk.PostgreSql; | ||
using SmartSql.DataSource; | ||
using SmartSql.Test.Entities; | ||
using Xunit; | ||
|
||
namespace SmartSql.Test.Unit.Bulk | ||
{ | ||
public class PostgreSqlTest | ||
{ | ||
[Fact] | ||
public void Insert() | ||
{ | ||
var dbSessionFactory = new SmartSqlBuilder() | ||
.UseDataSource(DbProvider.POSTGRESQL, "Server=localhost;Database=SmartTestDB;Port=5432;User Id=postgres;Password=SmartSql.net;") | ||
.Build().GetDbSessionFactory(); | ||
|
||
var list = new List<User> { | ||
new User {Id = 1, UserName = "1"} | ||
, new User {Id = 2, UserName = "2"} | ||
}; | ||
using (var dbSession = dbSessionFactory.Open()) | ||
{ | ||
var data = list.ToDataTable(); | ||
data.Columns.RemoveAt(0); | ||
data.Columns["UserName"].ColumnName = "user_name"; | ||
data.Columns["Status"].ColumnName = "status"; | ||
data.TableName = "t_user"; | ||
BulkInsert bulkInsert = new BulkInsert(dbSession); | ||
bulkInsert.Table = data; | ||
bulkInsert.Insert(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using SmartSql.Configuration; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
using System.Text; | ||
|
||
namespace SmartSql.TypeHandlers | ||
{ | ||
public class TypeHandlerCacheBuilder | ||
{ | ||
private AssemblyBuilder _assemblyBuilder; | ||
private ModuleBuilder _moduleBuilder; | ||
private void Init() | ||
{ | ||
string assemblyName = "SmartSql.TypeHandlerCacheBuilder" + this.GetHashCode(); | ||
_assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName | ||
{ | ||
Name = assemblyName | ||
}, AssemblyBuilderAccess.Run); | ||
_moduleBuilder = _assemblyBuilder.DefineDynamicModule(assemblyName + ".dll"); | ||
} | ||
|
||
public string CreateNameTypeHandlerCacheClassName(string typeHandlerName) | ||
{ | ||
return $"{typeHandlerName}_TypeHandler_{this.GetHashCode()}"; | ||
} | ||
|
||
public Type CreateNameTypeHandler(TypeHandler typeHandler) | ||
{ | ||
string className = CreateNameTypeHandlerCacheClassName(typeHandler.Name); | ||
var typeBuilder = _moduleBuilder.DefineType(className, TypeAttributes.Public); | ||
|
||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |