This article is a mirror article of machine translation, please click here to jump to the original article.

View: 22013|Reply: 1

[Source] linq delegates SQL statement splicing

[Copy link]
Posted on 8/5/2015 10:35:47 AM | | |
  1. /// <summary>
  2.         /// 请假数据
  3.         /// </summary>
  4.         /// <param name="ApplyUser">用户ID</param>
  5.         /// <param name="title">标题</param>
  6.         /// <param name="startTime">开始时间</param>
  7.         /// <param name="EndTime">结束时间</param>
  8.         /// <param name="Status">状态</param>
  9.         /// <param name="ye">分页</param>
  10.         /// <returns></returns>
  11.         public static List<Model.ViewApprove> GetApprove(string ApplyUser,string title,DateTime? startTime,DateTime? EndTime,byte Status, int ye)
  12.         {
  13.             bool tag=true;
  14.             Func<Model.ViewApprove,bool> fwhere = m =>
  15.             {
  16.                 tag = tag && m.ApplyUser == ApplyUser;
  17.                 if (title != ""&&title!=null)
  18.                   tag=tag&&m.Title.Contains(title);
  19.                 if (startTime!=null)
  20.                     tag = tag && m.ApplyDate >= startTime;
  21.                 if (EndTime != null)
  22.                     tag = tag && m.ApplyDate <= EndTime;
  23.                 if (Status != null)
  24.                     tag = tag && m.Status == Status;
  25.                 return tag;

  26.             };
  27.             return db.ViewApprove.Where(fwhere).Skip(ye).Take(10).ToList();
  28.         }
Copy code






Previous:Jay Chou's LOL live broadcast on August 4 is too fake!! Is the blind man on the other side asleep? EZ can also go to platinum over the tower?
Next:In August 2015, every Wednesday and Friday, the Wuhan International Convention and Exhibition Center held a job fair for Central China Talents
 Landlord| Posted on 8/7/2015 10:43:16 AM |
There are errors above, and the correct ones are:
  1. /// <summary>
  2.         /// 请假数据
  3.         /// </summary>
  4.         /// <param name="ApplyUser">用户ID</param>
  5.         /// <param name="title">标题</param>
  6.         /// <param name="startTime">开始时间</param>
  7.         /// <param name="EndTime">结束时间</param>
  8.         /// <param name="Status">状态</param>
  9.         /// <param name="ye">分页</param>
  10.         /// <returns></returns>
  11.         public static List<Model.ViewApprove> GetApprove(string ApplyUser,string title,DateTime? startTime,DateTime? EndTime,byte Status, int ye)
  12.         {
  13.          
  14.             Func<Model.ViewApprove,bool> fwhere = m =>
  15.             {
  16.                 bool cktitle = true;
  17.                 bool ckstartTime = true;
  18.                 bool ckEndTime = true;
  19.                 bool ckStatus = true;

  20.                
  21.                 if (title != ""&&title!=null)
  22.                     cktitle = m.Title.Contains(title);
  23.                 if (startTime!=null)
  24.                     ckstartTime = m.ApplyDate >= startTime;
  25.                 if (EndTime != null)
  26.                     ckEndTime = m.ApplyDate <= EndTime;
  27.                 if (Status != 2)
  28.                     ckStatus = m.Status == Status;
  29.                 return m.ApplyUser == ApplyUser && cktitle && ckstartTime && ckStatus;

  30.             };
  31.             return db.ViewApprove.Where(fwhere).Skip(ye).Take(10).ToList();
  32.         }
Copy code


Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com