protected virtual DataMember AppendMemberByCoalesce(DataMember left, ExpressionType expType, DataMember right) { var dataMembers = DataMemberUtil.GetKeyMember(left, right); var memberKey = ToParamMember(dataMembers.Item1); var memberValue = ToParamMember(dataMembers.Item2); AddParam(memberKey, memberValue); StringBuilder nameBuilder = new StringBuilder(); nameBuilder.AppendFormat("ISNULL({0},{1})", memberKey.Name, memberValue.Name); return(new DataMember(nameBuilder.ToString(), null, DataMemberType.None)); }
/// <summary> /// 拼接左边和右边参数的方法 /// </summary> /// <param name="left"></param> /// <param name="expType"></param> /// <param name="right"></param> /// <returns></returns> protected virtual DataMember AppendMember(DataMember left, ExpressionType expType, DataMember right) { if (left == null && right == null) { return(null); } if (expType == ExpressionType.Coalesce) { return(AppendMemberByCoalesce(left, expType, right)); } else { var dataMembers = DataMemberUtil.GetKeyMember(left, right); var memberKey = ToParamMember(dataMembers.Item1); var memberValue = ToParamMember(dataMembers.Item2); AddParam(memberKey, memberValue); StringBuilder nameBuilder = new StringBuilder(); nameBuilder.AppendFormat("({0} {1} {2})", memberKey?.Name, ResolveExpressionType(expType), memberValue?.Name); return(new DataMember(nameBuilder.ToString(), null, DataMemberType.None)); } }
private DataMember AppendMember(DataMember left, ExpressionType expType, DataMember right) { if (left == null && right == null) { return(null); } var dataMembers = DataMemberUtil.GetKeyMember(left, right); var memberKey = ToSqlMember(dataMembers.Item1); var memberValue = ToSqlMember(dataMembers.Item2); AddParam(memberKey, memberValue); StringBuilder nameBuilder = new StringBuilder(); if (expType == ExpressionType.Coalesce) { nameBuilder.AppendFormat("ISNULL({0},{1})", memberKey.Name, memberValue.Name); } else { nameBuilder.AppendFormat("({0} {1} {2})", memberKey?.Name, ResolveExpressionType(expType), memberValue?.Name); } return(new DataMember(nameBuilder.ToString(), null, DataMemberType.None)); }