导航属性规则制约、ISelect 增加 AsSelect 用于集合属性进行子查询,自动联表查询,以及MySql实现与部分测试

This commit is contained in:
28810
2019-03-16 08:00:07 +08:00
parent 23d5d33bdd
commit 3974c35b2f
54 changed files with 3423 additions and 2239 deletions

View File

@ -1,8 +1,12 @@
namespace FreeSql.Internal.Model {
using System.Linq.Expressions;
namespace FreeSql.Internal.Model {
class SelectTableInfo {
public TableInfo Table { get; set; }
public string Alias { get; set; }
public string On { get; set; }
public string NavigateCondition { get; set; }
public ParameterExpression Parameter { get; set; }
public SelectTableInfoType Type { get; set; }
}
enum SelectTableInfoType { From, LeftJoin, InnerJoin, RightJoin, Parent }

View File

@ -1,4 +1,5 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Reflection;
@ -15,5 +16,38 @@ namespace FreeSql.Internal.Model {
public string DbName { get; set; }
public string DbOldName { get; set; }
public string SelectFilter { get; set; }
ConcurrentDictionary<string, TableRef> _refs { get; } = new ConcurrentDictionary<string, TableRef>(StringComparer.CurrentCultureIgnoreCase);
internal void AddOrUpdateTableRef(string propertyName, TableRef tbref) {
_refs.AddOrUpdate(propertyName, tbref, (ok, ov) => tbref);
}
internal TableRef GetTableRef(string propertyName) {
if (_refs.TryGetValue(propertyName, out var tryref) == false) return null;
if (tryref.Exception != null) throw tryref.Exception;
return tryref;
}
}
internal class TableRef {
public PropertyInfo Property { get; set; }
public TableRefType RefType { get; set; }
public Type RefEntityType { get; set; }
/// <summary>
/// 中间表,多对多
/// </summary>
public Type RefMiddleEntityType { get; set; }
public List<ColumnInfo> Columns { get; set; } = new List<ColumnInfo>();
public List<ColumnInfo> MiddleColumns { get; set; } = new List<ColumnInfo>();
public List<ColumnInfo> RefColumns { get; set; } = new List<ColumnInfo>();
public Exception Exception { get; set; }
}
internal enum TableRefType {
OneToOne, ManyToOne, OneToMany, ManyToMany
}
}