首先我们来看看一个页面

这里面有多选的条件,大于,小于等等,包括每个字段都有

如此多的查询条件,我们的后台该如何实现呢?

难道我们还得每个参数都去判断吗?

那得传多少参数进来才能实现这个页面的功能啊!

既然用了EF当然不能在用sql拼接了

那么我们就来看看这个页面是怎么实现的吧

首先我们来看看这个页面的参数是怎么传到后台的

这是获取查询条件的脚本

  1. var filterRules = new Array();
  2. $(op.toolbarid).find("input[type!='button'][data-disable!='true'],select[data-disable!='true']").each(function () {
  3. var isadd = false;
  4. var value = $(this).val();
  5. if (this.type == "checkbox" || this.type == "radio") {
  6. isadd = this.checked;
  7. } else if (value) {
  8. isadd = true;
  9. }
  10. if (isadd) {
  11. var field = $(this).data("field");
  12. if (!field) {
  13. field = this.id;
  14. }
  15. var op = $(this).data("op");
  16. var time_add = $(this).data("time-add");
  17. if (time_add || $(this).data("time-today")) {
  18. if (time_add) {
  19. value = (new Date(Date.parse(value.replace(/-/g, "/")).getTime() + parseInt(time_add) * 86400000)).Format("yyyy-MM-dd");
  20. } else {
  21. var new_value = (new Date(Date.parse(value.replace(/-/g, "/")).getTime() + 86400000)).Format("yyyy-MM-dd");
  22. filterRules.push({ group: $(this).data("group"), field: field, op: "<", split: $(this).data("split"), value: new_value });
  23. op = ">=";
  24. }
  25. }
  26. filterRules.push({ group: $(this).data("group"), field: field, op: op, split: $(this).data("split"), value: value });
  27. }
  28. });
  29. options.filterRules = filterRules;

这是请求后台传递的参数

  1. [{"field":"FILE_TYPE","op":"=","split":",","value":"CAD,AD"},
  2. {"field":"WRITE_DATE","op":">=","value":"2011-01-01"},
  3. {"field":"WRITE_DATE","op":"<","value":"2016-04-14"},
  4. {"field":"STATUS","op":"=","split":",","value":"CLOSE,C/W"}]

后台代码

  1. return db.AWF_FILE_MAIN.Join(db.FLOW_TASK_INFO, d => d.FILE_NO, d => d.FILE_NO, (x, y) => new { ... })
  2. .Where(EasyuiFilterRules.GetWPList(wm.filterRules), wm.filterRules_isand)
  3. .ToPageJson(wm.page, wm.pageSize, wm.field, wm.order, DateTimeJson.Create(format: "yyyy-MM-dd"));

关键代码

.Where(EasyuiFilterRules.GetWPList(wm.filterRules), wm.filterRules_isand)

接下来我们就来看看Where背后的秘密,

我们先来看看EasyuiFilterRules类

EasyuiFilterRules主要的功能就是把JSON字符串转换成WhereParameters对象

  1. /// <summary>
  2. /// Easyui搜索规则
  3. /// </summary>
  4. public class EasyuiFilterRules
  5. {
  6. /// <summary>
  7. /// 字段名称
  8. /// </summary>
  9. public string field { get; set; }
  10.  
  11. /// <summary>
  12. /// 过滤类型,可选值有(contains-包含,equal-相等,notequal-不相等,beginwith-开头包含,endwith-结尾包含,less-小于,lessorequal-小于等于,greater-大于,greaterorequal-大于等于)
  13. /// </summary>
  14. public string op { get; set; }
  15.  
  16. /// <summary>
  17. /// 要搜索的值
  18. /// </summary>
  19. public string value { get; set; }
  20.  
  21. /// <summary>
  22. /// 组
  23. /// </summary>
  24. public int? group { get; set; }
  25.  
  26. /// <summary>
  27. /// 分隔符
  28. /// </summary>
  29. public string split { get; set; }
  30.  
  31. /// <summary>
  32. /// 方法
  33. /// </summary>
  34. public string fun { get; set; }
  35.  
  36. /// <summary>
  37. /// 获取过滤参数集合根据Easyui搜索规则字符串
  38. /// </summary>
  39. /// <param name="filterRules">Easyui搜索规则字符串</param>
  40. /// <returns>过滤参数集合</returns>
  41. public static List<WhereParameters> GetWPList(string filterRules)
  42. {
  43. var ps = new List<WhereParameters>();
  44. if (string.IsNullOrEmpty(filterRules))
  45. {
  46. return ps;
  47. }
  48. var list = JsonConvert.DeserializeObject<List<EasyuiFilterRules>>(filterRules);
  49. if (list.Count == )
  50. {
  51. return ps;
  52. }
  53. int index = -;
  54. foreach (var item in list)
  55. {
  56. if (string.IsNullOrEmpty(item.value))
  57. {
  58. continue;
  59. }
  60. var names = item.field.Split(',');
  61.  
  62. foreach (var name in names)
  63. {
  64. var values = item.value.Split(new string[]{item.split},StringSplitOptions.RemoveEmptyEntries);
  65. foreach (var value in values)
  66. {
  67. var wp = new WhereParameters(value, name, group: item.group ?? index,fun:item.fun);
  68. if (item.value == "is null")
  69. {
  70. wp.value = null;
  71. wp.isnotnull = false;
  72. wp.wherefun = WhereFun.Equal;
  73. }
  74. else if (item.value == "is not null")
  75. {
  76. wp.value = null;
  77. wp.isnotnull = false;
  78. wp.wherefun = WhereFun.NotEqual;
  79. }
  80. else
  81. {
  82. if (string.IsNullOrEmpty(item.op))
  83. {
  84. item.op = "contains";
  85. }
  86. switch (item.op.ToLower())
  87. {
  88. case "=":
  89. case "==":
  90. case "equal":
  91. case "eq": wp.wherefun = WhereFun.Equal; break;
  92.  
  93. case "!=":
  94. case "neq":
  95. case "notequal": wp.wherefun = WhereFun.NotEqual; break;
  96.  
  97. case "<":
  98. case "lt":
  99. case "less": wp.wherefun = WhereFun.LessThan; break;
  100.  
  101. case "<=":
  102. case "lte":
  103. case "lessorequal": wp.wherefun = WhereFun.LessThanOrEqual; break;
  104.  
  105. case ">":
  106. case "gt":
  107. case "greater": wp.wherefun = WhereFun.GreaterThan; break;
  108.  
  109. case ">=":
  110. case "gte":
  111. case "greaterorequal": wp.wherefun = WhereFun.GreaterThanOrEqual; break;
  112.  
  113. case "!c":
  114. case "doesnotcontain": wp.wherefun = WhereFun.NotContains; break;
  115.  
  116. case "^c":
  117. case "startswith": wp.wherefun = WhereFun.StartsWith; break;
  118.  
  119. case "c$":
  120. case "endswith": wp.wherefun = WhereFun.EndsWith; break;
  121.  
  122. case "like": wp.wherefun = WhereFun.Like; break;
  123.  
  124. case "notlike": wp.wherefun = WhereFun.NotLike; break;
  125.  
  126. default: wp.wherefun = WhereFun.Contains; break;
  127. }
  128. }
  129. ps.Add(wp);
  130. }
  131. }
  132. index--;
  133. }
  134. return ps;
  135. }
  136. }

接着我们看看WhereHelper类

就是这个类让Where方法可以接受.Where(EasyuiFilterRules.GetWPList(wm.filterRules), wm.filterRules_isand)这样的参数

代码也是相对比较简单的

  1. /// <summary>
  2. /// 搜索条件辅助类
  3. /// </summary>
  4. public static class WhereHelper
  5. {
  6. /// <summary>
  7. /// 根据条件过滤数据
  8. /// </summary>
  9. /// <typeparam name="model">指定的模型</typeparam>
  10. /// <param name="mls">对象</param>
  11. /// <param name="ps">过滤参数集合</param>
  12. /// <param name="isand">如果为true则同一组的进行Or运算,不同组的进行And运算,否则同一组的进行And运算,不同组的进行Or运算</param>
  13. /// <returns>对象</returns>
  14. public static IQueryable<model> Where<model>(this IQueryable<model> mls, List<WhereParameters> ps, bool isand = true)
  15. {
  16. if (ps.Count == )
  17. {
  18. return mls;
  19. }
  20. return mls.Where(WhereEx<model>.Create(ps, isand).ToFun());
  21. }
  22. }

继续WhereParameters,这个类也只是用来保存一些数据信息,没什么逻辑

  1. /// <summary>
  2. /// 过滤参数
  3. /// </summary>
  4. public class WhereParameters
  5. {
  6. /// <summary>
  7. /// 构造函数
  8. /// </summary>
  9. public WhereParameters()
  10. {
  11.  
  12. }
  13.  
  14. /// <summary>
  15. /// 构造函数
  16. /// </summary>
  17. /// <param name="value">要匹配的值</param>
  18. /// <param name="name">要匹配的字段名称</param>
  19. /// <param name="wherefun">匹配方法</param>
  20. /// <param name="isnotnull">值不为空才执行</param>
  21. /// <param name="group">组</param>
  22. /// <param name="fun">方法</param>
  23. public WhereParameters(object value, string name, WhereFun wherefun = WhereFun.Contains, bool isnotnull = true, int group = ,string fun="")
  24. {
  25. this.value = value;
  26. this.name = name;
  27. this.wherefun = wherefun;
  28. this.isnotnull = isnotnull;
  29. this.group = group;
  30. this.fun = fun;
  31. }
  32.  
  33. /// <summary>
  34. /// 判断是否要添加查询条件
  35. /// </summary>
  36. /// <returns>是否</returns>
  37. public bool IsAddWhere(Type type)
  38. {
  39. if (this.isnotnull && IsValueNull(type))
  40. {
  41. return false;
  42. }
  43. return true;
  44. }
  45.  
  46. /// <summary>
  47. /// 判断值是否为空
  48. /// </summary>
  49. /// <returns></returns>
  50. public bool IsValueNull(Type type)
  51. {
  52. return string.IsNullOrEmpty(Convert.ToString(this.value));
  53. }
  54.  
  55. /// <summary>
  56. /// 要匹配的值
  57. /// </summary>
  58. public object value { get; set; }
  59.  
  60. /// <summary>
  61. /// 要匹配的字段名称
  62. /// </summary>
  63. public string name { get; set; }
  64.  
  65. /// <summary>
  66. /// 匹配方法
  67. /// </summary>
  68. public WhereFun wherefun { get; set; }
  69.  
  70. /// <summary>
  71. /// 值不为空才执行
  72. /// </summary>
  73. public bool isnotnull { get; set; }
  74.  
  75. /// <summary>
  76. /// 组
  77. /// </summary>
  78. public int group { get; set; }
  79.  
  80. /// <summary>
  81. /// 方法
  82. /// </summary>
  83. public string fun { get; set; }
  84.  
  85. }

WhereParameters类所用到的枚举,也是查询所支持的比较方法

  1. /// <summary>
  2. /// 匹配方法
  3. /// </summary>
  4. public enum WhereFun
  5. {
  6. /// <summary>
  7. /// 包含
  8. /// </summary>
  9. Contains = ,
  10.  
  11. /// <summary>
  12. /// 相等
  13. /// </summary>
  14. Equal = ,
  15.  
  16. /// <summary>
  17. /// 不相等
  18. /// </summary>
  19. NotEqual = ,
  20.  
  21. /// <summary>
  22. /// 大于
  23. /// </summary>
  24. GreaterThan = ,
  25.  
  26. /// <summary>
  27. /// 大于等于
  28. /// </summary>
  29. GreaterThanOrEqual = ,
  30.  
  31. /// <summary>
  32. /// 小于
  33. /// </summary>
  34. LessThan = ,
  35.  
  36. /// <summary>
  37. /// 小于等于
  38. /// </summary>
  39. LessThanOrEqual = ,
  40.  
  41. /// <summary>
  42. /// 开始包含
  43. /// </summary>
  44. StartsWith = ,
  45.  
  46. /// <summary>
  47. /// 结束包含
  48. /// </summary>
  49. EndsWith = ,
  50.  
  51. /// <summary>
  52. /// 不包含
  53. /// </summary>
  54. NotContains = ,
  55.  
  56. /// <summary>
  57. /// 包含(支持通配符)
  58. /// </summary>
  59. Like = ,
  60.  
  61. /// <summary>
  62. /// 不包含(支持通配符)
  63. /// </summary>
  64. NotLike =
  65. }

重中之重还是WhereEx<T>类了,这是关键,主要是用了Expression表达式树实现的

  1. /// <summary>
  2. /// Where表达式
  3. /// </summary>
  4. /// <typeparam name="T">指定的模型</typeparam>
  5. public class WhereEx<T>
  6. {
  7. /// <summary>
  8. /// 表达式
  9. /// </summary>
  10. private Expression ex { get; set; }
  11.  
  12. /// <summary>
  13. /// 模型参数
  14. /// </summary>
  15. private ParameterExpression p_model { get; set; }
  16.  
  17. /// <summary>
  18. /// 构造参数
  19. /// </summary>
  20. /// <param name="ps">过滤参数</param>
  21. /// <param name="isand">如果为true则同一组的进行Or运算,不同组的进行And运算,否则同一组的进行And运算,不同组的进行Or运算</param>
  22. /// <returns>Where表达式</returns>
  23. public static WhereEx<T> Create(List<WhereParameters> ps, bool isand = true)
  24. {
  25. var model = new WhereEx<T>();
  26. model.p_model = Expression.Parameter(typeof(T), "p_model_where");
  27. if (ps == null || ps.Count == )
  28. {
  29. return model;
  30. }
  31. var grouplist = ps.GroupBy(d => d.group);
  32. if (isand)
  33. {
  34. foreach (var item in grouplist)
  35. {
  36. model.And(item.ToArray());
  37. }
  38. }
  39. else
  40. {
  41. foreach (var item in grouplist)
  42. {
  43. model.Or(item.ToArray());
  44. }
  45. }
  46. return model;
  47. }
  48.  
  49. /// <summary>
  50. /// 构造参数
  51. /// </summary>
  52. /// <param name="value">要匹配的值</param>
  53. /// <param name="name">要匹配的字段名称</param>
  54. /// <param name="wherefun">匹配方法</param>
  55. /// <param name="isnotnull">值不为空才执行</param>
  56. /// <returns>Where表达式</returns>
  57. public static WhereEx<T> Create(object value, string name, WhereFun wherefun = WhereFun.Contains, bool isnotnull = true)
  58. {
  59. var model = new WhereEx<T>();
  60. model.p_model = Expression.Parameter(typeof(T), "p_model_where");
  61. model.And(new WhereParameters(value, name, wherefun, isnotnull));
  62. return model;
  63. }
  64.  
  65. /// <summary>
  66. /// Where表达式And运算
  67. /// </summary>
  68. /// <param name="value">要匹配的值</param>
  69. /// <param name="name">要匹配的字段名称</param>
  70. /// <param name="wherefun">匹配方法</param>
  71. /// <param name="isnotnull">值不为空才执行</param>
  72. /// <returns>Where表达式</returns>
  73. public WhereEx<T> And(object value, string name, WhereFun wherefun = WhereFun.Contains, bool isnotnull = true)
  74. {
  75. return this.And(new WhereParameters(value, name, wherefun, isnotnull));
  76. }
  77.  
  78. /// <summary>
  79. /// Where表达式Or运算
  80. /// </summary>
  81. /// <param name="value">要匹配的值</param>
  82. /// <param name="name">要匹配的字段名称</param>
  83. /// <param name="wherefun">匹配方法</param>
  84. /// <param name="isnotnull">值不为空才执行</param>
  85. /// <returns>Where表达式</returns>
  86. public WhereEx<T> Or(object value, string name, WhereFun wherefun = WhereFun.Contains, bool isnotnull = true)
  87. {
  88. return this.Or(new WhereParameters(value, name, wherefun, isnotnull));
  89. }
  90.  
  91. /// <summary>
  92. /// Where表达式And运算
  93. /// </summary>
  94. /// <param name="ps">过滤参数(多个参数时先进行Or运算)</param>
  95. /// <returns>Where表达式</returns>
  96. public WhereEx<T> And(params WhereParameters[] ps)
  97. {
  98. var psex = this.GetWhereEx(false, ps);
  99. if (psex != null)
  100. {
  101. if (this.ex == null)
  102. {
  103. this.ex = Expression.Constant(true, typeof(bool));
  104. }
  105. this.ex = Expression.AndAlso(this.ex, psex);
  106. }
  107. return this;
  108. }
  109.  
  110. /// <summary>
  111. /// Where表达式Or运算
  112. /// </summary>
  113. /// <param name="ps">过滤参数(多个参数时先进行And运算)</param>
  114. /// <returns>Where表达式</returns>
  115. public WhereEx<T> Or(params WhereParameters[] ps)
  116. {
  117. var psex = this.GetWhereEx(true, ps);
  118. if (psex != null)
  119. {
  120. if (this.ex == null)
  121. {
  122. this.ex = Expression.Constant(false, typeof(bool));
  123. }
  124. this.ex = Expression.OrElse(this.ex, psex);
  125. }
  126. return this;
  127. }
  128.  
  129. /// <summary>
  130. /// Where表达式转方法
  131. /// </summary>
  132. /// <returns>方法</returns>
  133. public Expression<Func<T, bool>> ToFun()
  134. {
  135. if (this.ex == null)
  136. {
  137. this.ex = Expression.Constant(true, typeof(bool));
  138. }
  139. return Expression.Lambda<Func<T, bool>>(this.ex, this.p_model);
  140. }
  141.  
  142. /// <summary>
  143. /// 根据过滤参数获取表达式
  144. /// </summary>
  145. /// <param name="isand">是否是And运算</param>
  146. /// <param name="ps">过滤参数集合</param>
  147. /// <returns>表达式</returns>
  148. private Expression GetWhereEx(bool isand, params WhereParameters[] ps)
  149. {
  150. Expression psex = Expression.Constant(isand);
  151. if (ps.Length == )
  152. {
  153. return psex;
  154. }
  155. bool isaddps = false;
  156. #region 循环参数进行运算
  157.  
  158. foreach (var item in ps)
  159. {
  160. var pro = this.p_model.Type.GetProperty(item.name);
  161. if (pro == null)
  162. continue;
  163. if (!item.IsAddWhere(pro.PropertyType))
  164. {
  165. continue;
  166. }
  167. isaddps = true;
  168. var pro_type = pro.PropertyType;
  169. Expression left = Expression.Property(this.p_model, pro);
  170. if (!string.IsNullOrEmpty(item.fun))
  171. {
  172. item.fun = item.fun.ToLower();
  173. if (item.fun == "length")
  174. {
  175. left = Expression.Property(left, "Length");
  176. pro_type = typeof(int);
  177. }
  178. }
  179. Expression right = Expression.Constant(null);
  180. if (item.value!=null)
  181. {
  182. if (pro_type.IsGenericType && pro_type.GetGenericTypeDefinition() == typeof(Nullable<>))
  183. {
  184. right = Expression.Constant(Convert.ChangeType(item.value, (new System.ComponentModel.NullableConverter(pro_type)).UnderlyingType), pro_type);
  185. }
  186. else
  187. {
  188. right = Expression.Constant(Convert.ChangeType(item.value, pro_type), pro_type);
  189. }
  190. }
  191. Expression body = null;
  192. if (item.wherefun == WhereFun.Contains || item.wherefun == WhereFun.StartsWith || item.wherefun == WhereFun.EndsWith)
  193. {
  194. body = Expression.AndAlso(Expression.NotEqual(left, Expression.Constant(null, pro_type)), Expression.Call(left, pro_type.GetMethod(item.wherefun.ToString(), new Type[] { typeof(string) }), right));
  195. }
  196. else if (item.wherefun == WhereFun.NotContains)
  197. {
  198. body = Expression.AndAlso(Expression.NotEqual(left, Expression.Constant(null, pro_type)), Expression.Not(Expression.Call(left, pro_type.GetMethod(WhereFun.Contains.ToString(), new Type[] { typeof(string) }), right)));
  199. }
  200. //else if (item.wherefun == WhereFun.Like)
  201. //{
  202. // var like = typeof(System.Data.Entity.SqlServer.SqlFunctions).GetMethod("PatIndex", new Type[] { typeof(string), typeof(string) });
  203. // body = Expression.GreaterThan(Expression.Call(null, like, right, left), Expression.Constant(0, typeof(int?)));
  204. //}
  205. //else if (item.wherefun == WhereFun.NotLike)
  206. //{
  207. // var like = typeof(System.Data.Entity.SqlServer.SqlFunctions).GetMethod("PatIndex", new Type[] { typeof(string), typeof(string) });
  208. // body = Expression.Equal(Expression.Call(null, like, right, left), Expression.Constant(0, typeof(int?)));
  209. //}
  210. else if (item.wherefun == WhereFun.Equal)
  211. {
  212. if (item.IsValueNull(pro_type) && pro_type == typeof(string))
  213. {
  214. body = Expression.Call(null, typeof(string).GetMethod("IsNullOrEmpty", new Type[] { typeof(string) }), left);
  215. }
  216. else
  217. {
  218. body = Expression.Equal(left, right);
  219. }
  220. }
  221. else if (item.wherefun == WhereFun.NotEqual)
  222. {
  223. if (item.IsValueNull(pro_type) && pro_type == typeof(string))
  224. {
  225. body = Expression.Not(Expression.Call(null, typeof(string).GetMethod("IsNullOrEmpty", new Type[] { typeof(string) }), left));
  226. }
  227. else
  228. {
  229. body = Expression.NotEqual(left, right);
  230. }
  231. }
  232. else
  233. {
  234. #region 让字符串支持大于小于比较
  235. if (pro_type == typeof(string))
  236. {
  237. left = Expression.Call(left, pro_type.GetMethod("CompareTo", new Type[] { typeof(string) }), right);
  238. right = Expression.Constant();
  239. }
  240. #endregion
  241.  
  242. if (item.wherefun == WhereFun.GreaterThan)
  243. {
  244. body = Expression.GreaterThan(left, right);
  245. }
  246. else if (item.wherefun == WhereFun.GreaterThanOrEqual)
  247. {
  248. body = Expression.GreaterThanOrEqual(left, right);
  249. }
  250. else if (item.wherefun == WhereFun.LessThan)
  251. {
  252. body = Expression.LessThan(left, right);
  253. }
  254. else if (item.wherefun == WhereFun.LessThanOrEqual)
  255. {
  256. body = Expression.LessThanOrEqual(left, right);
  257. }
  258. if (body != null && pro_type == typeof(string))
  259. {
  260. body = Expression.AndAlso(Expression.NotEqual(Expression.Property(this.p_model, pro), Expression.Constant(null, pro_type)), body);
  261. }
  262. }
  263. if (isand)
  264. {
  265. psex = Expression.AndAlso(psex, body);
  266. }
  267. else
  268. {
  269. psex = Expression.OrElse(psex, body);
  270. }
  271. }
  272.  
  273. #endregion
  274. if (isaddps)
  275. {
  276. return psex;
  277. }
  278. else
  279. {
  280. return null;
  281. }
  282. }
  283.  
  284. }

最后附一些其它用法

EF之高级查询的更多相关文章

  1. MongoDB高级查询详细

    前言 前几篇,老玩家绕道即可,新手晚上闲着也是蛋疼,不如把命令敲一边,这样你就会对MongoDB有一定的掌握啦.如果没有安装MongoDB去看我的上一篇博客  MongoDB下载安装与简单增删改查 前 ...

  2. T-SQL高级查询语句

    高级查询 1.连接查询,对结果集列的扩展select * from info select * from info,nation #形成笛卡尔积select * from info,nation wh ...

  3. SQL Server高级查询

    简介 关于数据库,我们经常会听说"增查删改"之类的词语,听起来很简单,但是如果想要准确的获取到需要的数据的话,还是要花点功夫的.下面由我来和大家谈谈高级查询的用法以及和普通查询的区 ...

  4. mongodb高级查询

    前几篇,老玩家绕道即可,新手晚上闲着也是蛋疼,不如把命令敲一边,这样你就会对MongoDB有一定的掌握啦.如果没有安装MongoDB去看我的上一篇博客  MongoDB下载安装与简单增删改查 前奏:启 ...

  5. MySQL高级查询语句

    高级查询: 一:多表连接 1.select Info.Code,Info.Name,Nation.Name from Info,Nation where Info.Nation = Nation.Co ...

  6. 10月17日下午MySQl数据库CRUD高级查询

    高级查询:1.连接查询 #适用于有外键关系的  没有任何关系没法用select * from Info,Nation #同时查询这俩表并把两表每个数据相互组合,形成笛卡尔积 select * from ...

  7. Mysql 基础 高级查询

    在西面内容中    car  和  nation   都表示 表名 1.无论 高级查询还是简单查询   都用  select.. from..语句   from  后面 加表名  可以使一张表也可以是 ...

  8. LinQ 高级查询

    高级查询 模糊查(包含):.Contains(name) 开头:.StartsWith(name) 结尾:.EndsWith(name) 个数:.Count() 最大值:Max(r => r.p ...

  9. SNF开发平台WinForm之五-高级查询使用说明-SNF快速开发平台3.3-Spring.Net.Framework

    5.1运行效果: 5.2开发实现: 1.按上面效果来说,先来看一下在程序当中如果调用.第一步在页面拖拽一个按钮为“高级查询”,事件上写下如下代码: 如果是单表查询的话,只需要传GridView就行,如 ...

随机推荐

  1. [前端 2]常用的JQuery和Dom页面取值与赋值

    导读:书到用时方恨少,需要基础知识的时候,才悔恨自己没有总结学习好.前段时间调了好长时间的页面,突然发现自己之前不怎么在意的取值和赋值,真的是自己一个很薄弱的地方,有时候查半天都找不到一个对的,现在用 ...

  2. 延迟jquery,ready事件触发的时间

    $.holdReady(true);//holdReady必须在ready()方法调用之前来调用,来延迟ready()方法的执行 $(document).ready(function(){ conso ...

  3. OSI(Open System Interconnection)网络模型

    OSI模型是国际互连网标准化组织(International Standards Organizations ISO)所定义的,为了使网络的各个层次有标准.这个模型一般被称为“ISO OSI(Open ...

  4. TortoiseSVN文件夹图标不显示的解决方法

    是否遇到过TortoiseSVN安装好后,发现文件夹的图标还是Windows默认的图标? 下面通过简单几步解决图标不显示的问题. 1/6 "Win + R"打开运行框,输入&quo ...

  5. Oracle 11g 客户端 下载地址

    摘自: http://blog.csdn.net/davidhsing/article/details/8271845 Oracle Database Instant Client 11g 11.2. ...

  6. shp地图解析(不用AE)

    AE太重型,还收费,如果只是加载地图作为底图,可以用纯C#实现.线类型用得最多,以下是线类型的数据结构: 总体架构 文件头 记录头 记录内容 记录头 记录内容 ............ 记录头 记录内 ...

  7. C puzzles详解【6-8题】

    第六题 #include<stdio.h> int main() { ; switch(a) { ': printf("ONE\n"); break; ': print ...

  8. c#操作xml增删改查

    1.首先新建一个xml文件(Root是我写上的) 2. 3.直接上代码,更直观 (1)初始化xml /// <summary> /// 初始化xml /// </summary> ...

  9. 发送Ajax请求获取JSON格式数据

    Aspx前端页面: <script type="text/javascript"> $(function () { $.getJSON("Ajax/TestA ...

  10. NSLog的使用

    1.NSLog会将字符串打印在两个地方:操作系统的控制台和IDE的控制台. 2.对于NSLog来说,它打印的一个目的地并非控制台,而是系统文件“system.log”. 它另一个输出的目的地并非IED ...