1 class Program 2 { 3 public class post 4 { 5 public int id { get; set; } 6 public string name { get; set; } 7 public int age { get; set; } 8 public string pd { get; set; } 9 } 10 public class get 11 { 12 public int id { get; set; } 13 14 public string source { get; set; } 15 } 16 17 static void Main(string[] args) 18 { 19 20 21 var pro = new List<post> 22 { 23 new post { id = 1,name="123",age=1,pd="sad"}, 24 new post { id = 2,name="124",age=11,pd="sad"}, 25 new post { id =4,name="125",age=111,pd="sad"}, 26 new post {id = 5, name="126",age=1111,pd="sad"}, 27 }; 28 var prd = new List<get> 29 { 30 new get { id =1,source="123"}, 31 new get { id = 4,source="124s"}, 32 new get {id = 3, source="124d5"}, 33 new get {id = 6, source="12f6"}, 34 }; 35 36 var uds = pro.Join(prd, u => u.id, d => d.id, (u, d) => new { id = u.id, name = u.name, age = u.age, source = d.source }).ToList(); 37 //uds = [{ id = 1, name = "123", age = 1, source = "123" },{ id = 4, name = "125", age = 111, source = "124s" }]; 38 39 pro.ForEach(o => { o.pd = null; if (o.pd == null) o.pd = "sd"; });//批量处理 40 41 int pageIndex = 1, pageSize=10; //分页 42 pro.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); 43 44 var union = pro.Select(o => o.id).Union(prd.Select(o => o.id)).ToList() ; // 接表 45 Console.Read(); 46 47 } 48 49 }