- 增加 EfCoreFluentApi HasData 设定 CodeFirst 种子数据;

- 完善 EfCoreFluentApi 功能测试;
- 增加 DbContextOptions.NoneParameter 设置是否使用参数化执行 Insert/Update;
This commit is contained in:
28810
2020-04-03 08:55:56 +08:00
parent e5cbd407cb
commit 03fe0921ee
18 changed files with 339 additions and 78 deletions

View File

@ -8,22 +8,17 @@ namespace FreeSql.DataAnnotations
{
public class TableFluent
{
public TableFluent(ICodeFirst codeFirst, Type entityType, TableAttribute table)
public TableFluent(Type entityType, TableAttribute table)
{
_codeFirst = codeFirst;
_entityType = entityType;
_properties = _entityType.GetPropertiesDictIgnoreCase();
_table = table;
}
ICodeFirst _codeFirst;
Type _entityType;
Dictionary<string, PropertyInfo> _properties;
TableAttribute _table;
public void ConfigEntity<T2>(Action<TableFluent<T2>> fluent2) => _codeFirst.ConfigEntity<T2>(fluent2);
/// <summary>
/// 数据库表名
/// </summary>
@ -89,20 +84,15 @@ namespace FreeSql.DataAnnotations
public class TableFluent<T>
{
public TableFluent(ICodeFirst codeFirst, TableAttribute table)
public TableFluent(TableAttribute table)
{
_codeFirst = codeFirst;
_properties = typeof(T).GetPropertiesDictIgnoreCase();
_table = table;
}
ICodeFirst _codeFirst;
Dictionary<string, PropertyInfo> _properties;
TableAttribute _table;
public void ConfigEntity<T2>(Action<TableFluent<T2>> fluent2) => _codeFirst.ConfigEntity<T2>(fluent2);
/// <summary>
/// 数据库表名
/// </summary>
@ -131,7 +121,9 @@ namespace FreeSql.DataAnnotations
public ColumnFluent Property<TProto>(Expression<Func<T, TProto>> column)
{
var proto = (column.Body as MemberExpression)?.Member;
var exp = column?.Body;
if (exp?.NodeType == ExpressionType.Convert) exp = (exp as UnaryExpression)?.Operand;
var proto = (exp as MemberExpression)?.Member;
if (proto == null) throw new FormatException($"错误的表达式格式 {column}");
return Property(proto.Name);
}
@ -152,7 +144,9 @@ namespace FreeSql.DataAnnotations
/// <returns></returns>
public TableFluent<T> Navigate<TProto>(Expression<Func<T, TProto>> proto, string bind, Type manyToMany = null)
{
var member = (proto.Body as MemberExpression)?.Member;
var exp = proto?.Body;
if (exp.NodeType == ExpressionType.Convert) exp = (exp as UnaryExpression)?.Operand;
var member = (exp as MemberExpression)?.Member;
if (member == null) throw new FormatException($"错误的表达式格式 {proto}");
return Navigate(member.Name, bind, manyToMany);
}