/// <summary> /// 访问 EndWidth 方法 /// </summary> /// <param name="m">方法表达式</param> protected override Expression VisitEndsWith(MethodCallExpression m) { _visitor.Visit(m.Object); if (this.NotOperands != null && this.NotOperands.Contains(m)) { _builder.Append(" NOT"); } _builder.Append(" LIKE "); if (m.Arguments[0].CanEvaluate()) { ColumnAttribute column = null; bool isUnicode = MySqlUtils.IsUnicode(_visitedMark.Current, out column); string value = _constor.GetSqlValue(m.Arguments[0].Evaluate().Value, _builder.TranslateContext, column); if (!_builder.Parameterized && value != null) { value = value.TrimStart('N').Trim('\''); } if (_builder.Parameterized) { _builder.Append("CONCAT("); _builder.Append("'%',"); _builder.Append(value); _builder.Append(')'); } else { if (isUnicode) { _builder.Append('N'); } _builder.Append("'%"); _builder.Append(value); _builder.Append("'"); } } else { _builder.Append("CONCAT('%',"); _visitor.Visit(m.Arguments[0]); _builder.Append(")"); } return(m); }
///// <summary> ///// 检查字段或属性成员声明的 DbType 是否为 Unicode 数据类型 ///// </summary> ///// <param name="m">将要检查的字段或属性成员</param> ///// <returns></returns> //public static bool IsUnicode(MemberVisitedStack.VisitedMember m) //{ // ColumnAttribute column = null; // return DbTypeUtils.IsUnicode(m, out column); //} /// <summary> /// 检查字段或属性成员声明的 DbType 是否为 Unicode 数据类型 /// </summary> /// <param name="m">将要检查的字段或属性成员</param> /// <param name="column">字段或属性成员显示声明的列特性</param> /// <returns></returns> public static bool IsUnicode(MemberVisitedStack.VisitedMember m, out ColumnAttribute column) { column = m != null?TypeUtils.GetColumnAttribute(m.Member, m.ReflectedType) : null; return(MySqlUtils.IsUnicode(column == null ? null : column.DbType)); }