public static SqlExpressCommand Create(string sqlStatement,Query query) { SqlExpressCommand command = new SqlExpressCommand(); command.AppendStatement(sqlStatement); command.TranslateQuery(query); return command; }
private string GenerateCommand(string type) { ISqlExpressCommandGenerator commandGenerator = SqlExpressCommandGeneratorFactory.Create(); Query query = new Query(); query.Criteria.Add(new Criterion("GoodsName", CriteriaOperator.Like, "marcus")); Query subQuery = new Query(); query.SubQueries.Add(subQuery); query.Operator = QueryOperator.Or; subQuery.Criteria.Add(new Criterion("GoodsId", CriteriaOperator.GreaterThan, 90000)); SqlExpressCommand command=null; if (type == "R") command = commandGenerator.GenerateSelectCommand<Goods>(query); else if (type == "D") command = commandGenerator.GenerateDeleteCommand<Goods>(query); return command.Statement.ToString(); }
public SqlServerQueryTranslator(SqlExpressCommand sqlCommand, Query query) { _sqlCommand = sqlCommand; _query = query; }
public void TranslateQuery(Query query) { if (CommandType!=CommandType.Text) { throw new InvalidOperationException("只能为普通sql语句翻译查询"); } IQueryTranslator translator = QueryTranslatorFactory.Create(this, query); translator.Execute(); }
public static IQueryTranslator Create(SqlExpressCommand command,Query query) { return new SqlServerQueryTranslator(command,query); }
public QueryTranslator(ICriteria criteria, Query query) { _criteria = criteria; _query = query; }