/// <summary> /// 处理where条件表达式,如果表达式为空,默认使用Id /// </summary> /// <param name="visitor"></param> /// <param name="exp"></param> /// <param name="visType"></param> private static string GetVisitExpressSql(SqlExpressionVisitor visitor, Expression exp, SqlVistorType visType) { if (visType == SqlVistorType.Update) { var updateFlag = new SqlVistorFlag(SqlVistorType.Update); visitor.Visit(exp, updateFlag); return(updateFlag.sql); } string sql; if (exp == null) { throw new ArgumentNullException("whereExp", "where表达式不能为空!"); } else { var whereFlag = new SqlVistorFlag(SqlVistorType.Where); visitor.Visit(exp, whereFlag); sql = string.Concat(" WHERE ", whereFlag.sql); } return(sql); }
/// <summary> /// 处理where条件表达式,如果表达式为空,默认使用Id /// </summary> /// <param name="visitor"></param> /// <param name="exp"></param> /// <param name="visType"></param> private static string GetVisitExpressSql(SqlExpressionVisitor visitor, Expression exp, SqlVistorType visType) { if (visType == SqlVistorType.Update) { var updateFlag = new SqlVistorFlag(SqlVistorType.Update); visitor.Visit(exp, updateFlag); return(updateFlag.Sql); } string sql; if (exp == null) { sql = " WHERE id=@id"; } else { var whereFlag = new SqlVistorFlag(SqlVistorType.Where); visitor.Visit(exp, whereFlag); sql = string.Concat(" WHERE ", whereFlag.Sql); } return(sql); }
/// <summary> /// 处理where条件表达式,如果表达式为空,默认使用Id /// </summary> /// <param name="visitor"></param> /// <param name="exp"></param> /// <param name="visType"></param> private static string GetVisitExpressSql(SqlExpressionVisitor visitor, Expression exp, SqlVistorType visType) { if (visType == SqlVistorType.Update) { var updateFlag = new SqlVistorFlag(SqlVistorType.Update); visitor.Visit(exp, updateFlag); return(updateFlag.Sql); } var whereFlag = new SqlVistorFlag(SqlVistorType.Where); visitor.Visit(exp, whereFlag); var sql = string.Concat(" WHERE ", whereFlag.Sql); return(sql); }
public SqlVistorFlag(SqlVistorType vistorType) { VistorType = vistorType; _sqlBuilder = new StringBuilder(); UnaryType = (ExpressionType)(-1); }
public SqlVistorFlag(SqlVistorType vistorType) { VistorType = vistorType; sqlBuilder = new StringBuilder(); }