Ejemplo n.º 1
0
 public IList<IModel> Filter(IModel m, Condition condition, MPager mp = null, OrderBy orderby = null)
 {
     var dic = FilterWithId(m, condition, mp, orderby);
     if (dic != null && dic.Count > 0)
     {
         return dic.Values.ToList();
     }
     return null;
 }
Ejemplo n.º 2
0
        public IDictionary<long, IModel> FilterWithId(IModel m, Condition condition, MPager mp = null, OrderBy orderby = null)
        {
            if (m == null)
            {
                throw new Exception("Model Class Must Implements the interface IModel");
            }
            string sqlexp = "select {0} from {1} where {2} ";
            var dicols = MReflection.GetModelColumns(m);
            string columns = string.Join(",", dicols.Values);

            var plist = Db.DbEngine.NewParameters();
            string condstr = condition.ToString(m, plist);
            string orderbystr = orderby == null ? "" : orderby.ToString(m);
            string sql = string.Format(sqlexp, new string[] { columns, m.zTableName, condstr });

            if (mp != null)
            {
                sql = DbEngine.Instance.GetPagerSql(sql, orderbystr, mp.PageIndex, mp.PageSize, out mp.TotalCount, plist.Values.ToArray());
            }
            else
            {
                sql += orderbystr;
            }

            var ds = DbEngine.Instance.ExecuteQuery(sql, plist.Values.ToArray());

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                var dic = BindData.BindDataByTableWithId(m.zModelType, ds.Tables[0]);
                if (dic != null && dic.Count > 0)
                {
                    Dictionary<long, IModel> ddd = new Dictionary<long, IModel>();
                    foreach (var d in dic.Keys)
                    {
                        ddd.Add(d, dic[d] as IModel);
                    }
                    return ddd;
                }
            }
            return new Dictionary<long, IModel>();
        }
Ejemplo n.º 3
0
 public OrderBy(string name, bool isdesc = true, OrderBy right = null)
 {
     Name = name;
     Desc = isdesc;
     Right = right;
 }
Ejemplo n.º 4
0
 public OyOrderBy(string name, bool isdesc = true, OrderBy right = null)
     : base(name, isdesc, right)
 {
 }