示例#1
0
        static void Main(string[] args)
        {
            //Model model=new Model(){Id=10,Name = "life2",CreateDate = DateTime.Now};
            DbApi api=new DbApi();
            //api.Update(model);
            //api.Insert(model);
            Condition A1=new Condition("Id",1,Op.Equal);
            Condition A2=new Condition("Id",3,Op.Equal);
            Condition A3=new Condition("Name","life",Op.NotEqual);
            Query query = new Query()
                {
                    WhereExpression = new OpExpression(new OpExpression(new OpExpression(A1),new OpExpression(A2),JoinOP.Or ), new OpExpression(A3), JoinOP.And)
                };
            var list=api.Select<Model>(query);

            //api.Insert(model);
            //api.Delete(model);
        }
示例#2
0
 public string SelectMaker(Query query,string tableName)
 {
     StringBuilder sb=new StringBuilder();
     sb.Append("Select * from _TableName Where 1=1 And ");
     string queryStr = MakeWhereStr(query.WhereExpression);
     string orderBy = "";
     string ASC = query.ASC ? "ASC" : "DESC";
     sb.Append(queryStr);
     if (string.IsNullOrEmpty(query.Orderby))
     {
         orderBy = " Order By Id ASC";
     }
     else
     {
         orderBy = " Order By " + query.Orderby + ASC;
     }
     sb.Append(orderBy);
     sb.Replace("_TableName", tableName);
     return sb.ToString();
 }