This commit is contained in:
sunkaixuan
2017-05-15 20:44:06 +08:00
parent d532289a3e
commit 910c00fb16
3 changed files with 59 additions and 24 deletions

View File

@@ -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" />

View 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;
}
}
}

View File

@@ -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;
});
}