完善 CodeFirst

This commit is contained in:
28810
2018-12-25 20:41:15 +08:00
parent 2a115ffcfe
commit 9c3e844e97
30 changed files with 3265 additions and 324 deletions

View File

@ -26,7 +26,8 @@ namespace FreeSql.Internal.CommonProvider {
switch (expCall.Method.Name) {
case "Where": this.InternalWhere(expCall.Arguments[0]); break;
case "WhereIf":
if (_commonExpression.ExpressionSelectColumn_MemberAccess(null, null, SelectTableInfoType.From, expCall.Arguments[0], false) == "1")
var whereIfCond = _commonExpression.ExpressionSelectColumn_MemberAccess(null, null, SelectTableInfoType.From, expCall.Arguments[0], false);
if (whereIfCond == "1" || whereIfCond == "'t'")
this.InternalWhere(expCall.Arguments[1]);
break;
case "GroupBy": this.InternalGroupBy(expCall.Arguments[0]); break;

View File

@ -66,7 +66,7 @@ namespace FreeSql.Internal.CommonProvider {
if (cols.Any() == false) return this;
foreach (var col in cols) {
if (col.Column.Attribute.IsNullable) {
var replval = col.Column.Attribute.DbDefautValue;
var replval = _orm.CodeFirst.GetDbInfo(col.Column.CsType.GenericTypeArguments.FirstOrDefault())?.defaultValue;
if (replval == null) continue;
var replname = _commonUtils.QuoteSqlName(col.Column.Attribute.Name);
expt = expt.Replace(replname, _commonUtils.IsNull(replname, _commonUtils.FormatSql("{0}", replval)));