1 [Table("TestGuid")] 2 public class TestGuidContract : BaseContract 3 { 4 public TestGuidContract() 5 { 6 Name = string.Empty; 7 } 8 9 10 [Key] 11 public string GuidKey { get; set; } 12 13 public string Name { get; set; } 14 } 15 16 17 public class TimeBottleContext : DbContext 18 { 19 public DbSet<TestGuidContract> TestGuid { get; set; } 20 21 } 22 23 24 25 26 public JsonResult TestGuidKey() 27 { 28 using (var context = new TimeBottleContext()) 29 { 30 //for (int i = 1; i <= 10; i++) 31 //{ 32 // context.TestGuid.Add(new TestGuidContract { GuidKey = Guid.NewGuid().ToString(), Name = "nlh" + i }); 33 //} 34 //context.SaveChanges(); 35 36 var resp = context.TestGuid.ToList(); 37 return Json(resp, JsonRequestBehavior.AllowGet); 38 } 39 } 40 41 public JsonResult GetTestGuidKey(string guidKey = "0484dc28-ccab-44e1-9978-904491a6c7ce") 42 { 43 using (var context = new TimeBottleContext()) 44 { 45 var resp = context.TestGuid.FirstOrDefault(t => t.IsDel == false && t.GuidKey == guidKey); 46 return Json(resp, JsonRequestBehavior.AllowGet); 47 } 48 }