private static Model2Sql GetOrderSQL <T>(IOrder order) { if (order == null) { throw new ArgumentException("order不能为空"); } if (order.All().Count <= 0) { throw new ArgumentException("order中没有可排序字段"); } int n = 1; string orderSql = string.Empty; foreach (var item in order.All()) { if (!ReflectionHelper.ExistField <T>(item.Key)) { throw new ArgumentException(string.Format("此字段{0}不存在类中", item.Key)); } if (n != 1) { orderSql = orderSql + " , "; } orderSql += " " + item.Key + " " + item.Value.ToString(); n++; } Model2Sql model = new Model2Sql() { Sql = orderSql, SqlType = Model2Db.Query }; return(model); }