今天项目中用到了,特记录一下 一. List<Map> 如果 item.get(sortField) 有时间,有数字的时候直接toString(),数组结果的排序结果可能不正确 List<Map<String, Object>> resourceCatalogFrontVoList = resourceMapper.selectPublishResourceCatalogList(keyWord, sysId, shareType, openAttribute, cla…
利用Entity Framework修改指定字段中的值一般我们编辑某些模型的时候会用到类似这样的代码: [HttpPost] public ActionResult Edit(Article model) { if (model.Id == 0) { return HttpNotFound(); } using (db) { db.Entry(model).State = EntityState.Modified; db.SaveChanges(); } return RedirectToAct…
在开发中,有时会需要指定字段去重,以下为实现方法: 假设有个房地产权的类,其中宗地代码ZDDM值重复,而我们在前端页面显示时,只需要一条数据,因为公共字段都一样: IEqualityComparer需引入程序集——using System.Collections; //集合指定字段去重(宗地代码) List<FDCQClient> resultFDCQ = new List<FDCQClient>(); var resultdis=resultFDCQ.Distinct(new M…
1.ef修改时指修改指定字段public void ChangePassword(int userId, string password) { var user = new User() { Id = userId, Password = password }; using (var db = new MyEfContextName()) { db.Users.Attach(user); db.Entry(user).Property(x => x.Password).IsModified =…
public class Book { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } [Required, MaxLength()] public string Title { get; set; } public Double? Price { get; set; } } 解决方案一: var bkList = db.Books.Select(allBooks =>…
using System; using System.Collections.Generic; namespace ConsoleApplication1 { class Product { public string Name { get; private set; } public decimal Price { get; private set; } public Product(string name, decimal price) { Name = name; Price = pric…
//把需要比较的对象实现Comparable接口实现compareTo方法 public class Address implements Comparable<Address> { String country; String city; String name; public Address(String country, String city, String name) { super(); this.country = country; this.city = city; this.…
可以连续使用:OrderBy,ThenBy 或者 OrderByDescending,ThenByDescending var data = db.User .Where(u => u.UserId != && u.DeleteMark == ) .Select(u => new { u.UserId, u.EnCode, u.Account, u.RealName, u.Gender, u.Birthday, u.Mobile, u.Manager, u.OrganizeId…
转自:http://blog.csdn.net/wangjuan_01/article/details/51351633 List集合按某个字段排序 package wjtest_01; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; public class ListSort<E> { @SuppressWarnings(…
------- android培训.java培训.期待与您交流! ---------- Map集合: 该集合存储键值对.一对一对往里存.而且要保证键的唯一性. 和Set很像,其实Set底层就是使用了Map集合. Map与Collection:    Map与Collection在集合框架中属并列存在    Map存储的是键值对    Map存储元素使用put方法,Collection使用add方法    Map集合没有直接取出元素的方法,而是先转成Set集合,在通过迭代获取元素    Map集合…