ICodeFirst 增加 ConfigEntity 方法,现实干净实体无特性的需求

This commit is contained in:
28810
2019-01-22 12:56:45 +08:00
parent 0bcacc706a
commit 4bf8d60361
22 changed files with 270 additions and 65 deletions

View File

@ -283,8 +283,8 @@ namespace FreeSql.Internal.CommonProvider {
if (dicfield.ContainsKey(quoteName)) field.Append(" as").Append(index);
else dicfield.Add(quoteName, true);
} else {
var tb2 = _tables.Where(a => a.Table.Type == prop.PropertyType && a.Alias.Contains(prop.Name)).FirstOrDefault();
if (tb2 == null && props.Where(pw => pw.Value.PropertyType == prop.PropertyType).Count() == 1) tb2 = _tables.Where(a => a.Table.Type == prop.PropertyType).FirstOrDefault();
var tb2 = _tables.Where((a, b) => b > 0 && a.Table.Type == prop.PropertyType && a.Alias.Contains(prop.Name)).FirstOrDefault(); //判断 b > 0 防止 parent 递归关系
if (tb2 == null && props.Where(pw => pw.Value.PropertyType == prop.PropertyType).Count() == 1) tb2 = _tables.Where((a, b) => b > 0 && a.Table.Type == prop.PropertyType).FirstOrDefault();
if (tb2 == null) continue;
foreach (var col2 in tb2.Table.Columns.Values) {
if (index > 0) field.Append(", ");

View File

@ -74,7 +74,7 @@ namespace FreeSql.Internal.CommonProvider {
var expt = _commonExpression.ExpressionWhereLambdaNoneForeignObject(null, cols, binaryExpression, null);
if (cols.Any() == false) return this;
foreach (var col in cols) {
if (col.Column.Attribute.IsNullable) {
if (col.Column.Attribute.IsNullable == true) {
var replval = _orm.CodeFirst.GetDbInfo(col.Column.CsType.GenericTypeArguments.FirstOrDefault())?.defaultValue;
if (replval == null) continue;
var replname = _commonUtils.QuoteSqlName(col.Column.Attribute.Name);