public TField GetField <TField>(ParamQuery param) { var result = default(TField); var command = GetPreparedDbCommand(BuilderParse(param).Data); return(command == null ? result : command.QuerySingle <TField>()); }
public ParamQuery ToParamQuery() { var pQuery = new ParamQuery(); var settings = XElement.Parse(settingXml); var defaultOrderBy = getXmlElementAttr(settings, "defaultOrderBy"); pQuery.Select(getXmlElementValue(settings, "select")); //获取分页及排序信息 var page = parseInt(request["page"], 1); var rows = parseInt(request["rows"]); var orderby = string.Join(" ", GetFieldName(this["sort"], true), this["order"]).Trim(); if (string.IsNullOrEmpty(orderby)) { orderby = defaultOrderBy; } var sFrom = getXmlElementValue(settings, "from"); var sGroupby = getXmlElementValue(settings, "groupby"); pQuery.From(sFrom).Paging(page, rows).OrderBy(orderby).GroupBy(sGroupby); ParseWhere(settings, (name, value, compare, variable, extend) => { pQuery.AndWhere(name, value, compare, extend); }); return(pQuery); }
public T GetModel(ParamQuery param) { //Logger("获取实体对象", () => result = BuilderParse(param).QuerySingle()); var result = BuilderParse(param).QuerySingle(); return(result); }
public dynamic GetDynamic(ParamQuery param) { var result = new ExpandoObject(); var command = GetPreparedDbCommand(BuilderParse(param).Data); return(command == null ? result : command.QuerySingle <dynamic>()); }
public dynamic GetDynamicListWithPaging(ParamQuery param = null) { dynamic result = new ExpandoObject(); result.rows = this.GetDynamicList(param); result.total = this.QueryRowCount(param); return(result); }
protected int QueryRowCount(ParamQuery param) { var data = param.GetData(); var sFrom = data.From.Length == 0 ? typeof(T).Name : data.From; var selectBuilder = db.Select <int>("COUNT(1)") .From(sFrom) .Where(data.WhereSql); return(selectBuilder.QuerySingle()); }
public List <T> GetList(ParamQuery param = null) { IDbCommand command = GetPreparedDbCommand(BuilderParse(param).Data); if (command == null) { return(new List <T>()); } var result = command.QueryMany <T>(); return(result); }
protected ISelectBuilder <T> BuilderParse(ParamQuery param) { if (param == null) { param = new ParamQuery(); } var data = param.GetData(); var sFrom = data.From.Length == 0 ? typeof(T).Name : data.From; var selectBuilder = db.Select <T>(string.IsNullOrEmpty(data.Select) ? (sFrom + ".*") : data.Select) .From(sFrom) .Where(data.WhereSql) .GroupBy(data.GroupBy) .Having(data.Having) .OrderBy(data.OrderBy) .Paging(data.PagingCurrentPage, data.PagingItemsPerPage); return(selectBuilder); }
public List <T> GetModelList(ParamQuery param = null) { return(BuilderParse(param).QueryMany()); }