mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-12-02 03:13:58 +08:00
-
This commit is contained in:
@@ -64,6 +64,7 @@
|
||||
<Compile Include="UnitTest\ExpressionTest\ExpTestBase.cs" />
|
||||
<Compile Include="UnitTest\ExpressionTest\Field.cs" />
|
||||
<Compile Include="UnitTest\Insert.cs" />
|
||||
<Compile Include="UnitTest\Mapping .cs" />
|
||||
<Compile Include="UnitTest\Query\JoinQuery.cs" />
|
||||
<Compile Include="UnitTest\ExpressionTest\Method.cs" />
|
||||
<Compile Include="UnitTest\ExpressionTest\Select.cs" />
|
||||
|
||||
31
OrmTest/UnitTest/Mapping .cs
Normal file
31
OrmTest/UnitTest/Mapping .cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using OrmTest.Models;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrmTest.UnitTest
|
||||
{
|
||||
public class Mapping:ExpTestBase
|
||||
{
|
||||
private Mapping() { }
|
||||
public Mapping(int eachCount)
|
||||
{
|
||||
this.Count = eachCount;
|
||||
}
|
||||
|
||||
public void Init() {
|
||||
|
||||
var db = GetInstance();
|
||||
var s1= db.Queryable<Student>().ToSql();
|
||||
}
|
||||
|
||||
public SqlSugarClient GetInstance()
|
||||
{
|
||||
SqlSugarClient db = new SqlSugarClient(new AttrbuitesCofnig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true, EntityNamespace= "OrmTest.Models" });
|
||||
return db;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,9 @@ namespace SqlSugar
|
||||
{
|
||||
this.GetTableInfoList();
|
||||
}
|
||||
var entity = this.Context.MappingTables.SingleOrDefault(it => it.DbTableName.Equals(tableName, StringComparison.CurrentCultureIgnoreCase));
|
||||
var entities = this.Context.MappingTables.Where(it => it.DbTableName.Equals(tableName, StringComparison.CurrentCultureIgnoreCase)).ToList();
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
var entityName = entity == null ? tableName : entity.EntityName;
|
||||
var assembly = Assembly.Load(this.Context.EntityNamespace.Split('.').First());
|
||||
foreach (var item in assembly.GetType(this.Context.EntityNamespace + "." + entityName).GetProperties())
|
||||
@@ -116,6 +118,7 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return reval;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user