## v0.5.1(五一版)

- 增加 ISelect/IInsert/IUpdate/IDelete.AsType 实现弱类型curd,如:Select<object>().AsType(实体类型);
- 补充 ISelect.From<T2>;
- 补充 ExpressionTree 单元测试;
- 优化 ToList(a => new Dto()),会按优先级查询 Join 实体属性;
- 补充 IDelete/ISelect/IUpdate WhereDynamic 方法,实现 dywhere 条件;
- 修复 WhereObject 内部方法,当开启 Lazy 延时属性时,并且传递实体查询时条件无效;
This commit is contained in:
28810
2019-04-17 00:52:02 +08:00
parent f011d51f3b
commit bada8ad3cc
12 changed files with 88 additions and 38 deletions

View File

@@ -30,7 +30,7 @@ namespace FreeSql.Internal.CommonProvider {
_commonExpression = commonExpression;
_table = _commonUtils.GetTableByEntity(typeof(T1));
_noneParameter = _orm.CodeFirst.IsNoneCommandParameter;
if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure<T1>();
if (_orm.CodeFirst.IsAutoSyncStructure && typeof(T1) != typeof(object)) _orm.CodeFirst.SyncStructure<T1>();
}
protected void ClearData() {
@@ -356,6 +356,15 @@ namespace FreeSql.Internal.CommonProvider {
_tableRule = tableRule;
return this;
}
public IInsert<T1> AsType(Type entityType) {
if (entityType == typeof(object)) throw new Exception("IInsert.AsType 参数不支持指定为 object");
if (entityType == _table.Type) return this;
var newtb = _commonUtils.GetTableByEntity(entityType);
_table = newtb ?? throw new Exception("IInsert.AsType 参数错误,请传入正确的实体类型");
if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure(entityType);
return this;
}
public virtual string ToSql() {
if (_source == null || _source.Any() == false) return null;
var sb = new StringBuilder();