





















先来看实际调用例子
public JsonResult List(int? TotalCount, int? StartRecord, int? PageSize, string OrderBy)
{
QueryInfo info = new QueryInfo(typeof(ProcessDefinitionEntity));//结果集转换
info.AddParam(WebHelper.Web.UI.BindingPanel.SaveData<System.Collections.Hashtable>(Request.Form, 0));//查询参数组装
base.SetPagingInfo(info, TotalCount, StartRecord, PageSize, OrderBy);//分页信息
info.CustomSQL = "selectProcessDefinitionsByQueryCriteria";//Mapping SQL
return Json(dao.Select(info));//Do the job!
}
在WorkFlow.xml 中,配置了如下的mapping
<add key="selectTaskByQueryCriteria" value="select distinct T.* from ACT_RU_TASK T
{ inner join ACT_RU_IDENTITYLINK I on I.TASK_ID_ = T.ID_ [candidateUser|candidateGroups|involvedUser]}
{ inner join ACT_RE_PROCDEF D on T.PROC_DEF_ID_ = D.ID_ [processDefinitionKey|processDefinitionName]}
{ where 1=1 }
{ and T.ID_ = :taskId}
{ and T.NAME_ = :name}
{ and T.NAME_ like :nameLike}
{ and T.DESCRIPTION_ = :description}
{ and T.DESCRIPTION_ like :descriptionLike}
{ and T.PRIORITY_ = :priority}
{ and T.PRIORITY_ >= :minPriority}
{ and T.PRIORITY_ <= :maxPriority}
大括号{}内都是动态语句, 中括号[]内都是匹配条件。 当条件不给定时, 默认取参数有值为条件; 当参数也不存在时,默认语句总是有效。
一旦大括号{}启动,则后续的语句都必须是动态语句。
如第一个innerjoin: 当candidate条件任一个参数给定 时(或条件), 则启用该语句。 同样可以使用 & 作为 与条件。
当界面Form提供参数 : txt_name_ 的值时 则启用 and T.NAME_ = :name 语句。
当界面Form提供参数: txt_CreatedOn_GEQ_ 的值时, 由于mapping未找到匹配, 则自动创建语句: and T.CreatedOn >= :CreatedOnGEQ
当界面Form提供参数: txt_CreatedOn_VAL_ 的值时, 由于mapping未找到匹配,VAL仅提供value, 所以改条件自动忽略。
其余的Criteria 有: LK, RLK,LLK, EQ,GEQ,LEQ,
尤其便利的还有多个条件LK, 多参数IN的语句自动组装。
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。