mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 12:28:15 +08:00
- 增加 [Navigate(xx, TempPrimary = xx)] 与非主键关联;(仅支持查询)
This commit is contained in:
@ -38,7 +38,7 @@ namespace FreeSql.Internal.Model
|
||||
{
|
||||
_refs.AddOrUpdate(propertyName, tbref, (ok, ov) => tbref);
|
||||
}
|
||||
public TableRef GetTableRef(string propertyName, bool isThrowException)
|
||||
public TableRef GetTableRef(string propertyName, bool isThrowException, bool isCascadeQuery = true)
|
||||
{
|
||||
if (_refs.TryGetValue(propertyName, out var tryref) == false) return null;
|
||||
if (tryref.Exception != null)
|
||||
@ -46,6 +46,18 @@ namespace FreeSql.Internal.Model
|
||||
if (isThrowException) throw tryref.Exception;
|
||||
return null;
|
||||
}
|
||||
if (isCascadeQuery == false && tryref.IsTempPrimary == true)
|
||||
{
|
||||
if (isThrowException)
|
||||
{
|
||||
switch (tryref.RefType)
|
||||
{
|
||||
case TableRefType.OneToMany: throw new Exception($"[Navigate(\"{string.Join(",", tryref.RefColumns.Select(a => a.CsName))}\", TempPrimary = \"{string.Join(",", tryref.Columns.Select(a => a.CsName))}\")] Only cascade query are supported");
|
||||
case TableRefType.ManyToOne: throw new Exception($"[Navigate(\"{string.Join(",", tryref.Columns.Select(a => a.CsName))}\", TempPrimary = \"{string.Join(",", tryref.RefColumns.Select(a => a.CsName))}\")] Only cascade query are supported");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return tryref;
|
||||
}
|
||||
public IEnumerable<KeyValuePair<string, TableRef>> GetAllTableRef() => _refs;
|
||||
@ -160,6 +172,7 @@ namespace FreeSql.Internal.Model
|
||||
public List<ColumnInfo> RefColumns { get; set; } = new List<ColumnInfo>();
|
||||
|
||||
public Exception Exception { get; set; }
|
||||
public bool IsTempPrimary { get; set; }
|
||||
}
|
||||
public enum TableRefType
|
||||
{
|
||||
|
Reference in New Issue
Block a user