Easyobjects构建复杂查询 (BY 冷家锋)

一、目标:实现如下查询
select * from class2 where
COL1='1'
or (COL1='2' and COL2='4')
or (COL1='3' and COL3='5')

二、起作用的查询代码片段
            class2.Where.COL1.Value = "1";
            class2.Query.AddConjunction(NCI.EasyObjects.WhereParameter.Conj.Or);
            class2.Query.OpenParenthesis();
            class2.Where.TearOff.COL1.Value = "2";
            class2.Where.COL2.Conjunction = NCI.EasyObjects.WhereParameter.Conj.And;
            class2.Where.COL2.Value = "4";
            class2.Query.CloseParenthesis();
            class2.Query.AddConjunction(NCI.EasyObjects.WhereParameter.Conj.Or);
            class2.Query.OpenParenthesis();
            class2.Where.TearOff.COL1.Value = "3";
            class2.Where.COL3.Conjunction = NCI.EasyObjects.WhereParameter.Conj.And;
            class2.Where.COL3.Value = "5";
            class2.Query.CloseParenthesis();
            class2.Query.Load();
            string str = class2.Query.LastQuery;

你可能感兴趣的:(String,Class)