public bool PutEntity(EntityDemo value) { try { AddEntity.Enqueue(value); return(true); } catch (Exception ex) { Console.WriteLine(ex.ToString()); return(false); } }
/// <summary> /// Demo:使用EF /// </summary> /// <param name="key"></param> /// <returns></returns> //public EntityDemo GetEntity(EntityDemoIdentity key) //{ // EntityDemo EntityDemo = get(Convert.ToInt32(key.ID())); // if (EntityDemo == null) // { // using (testContext testContext = new testContext()) // { // Student data =testContext.Student.Find(Convert.ToInt32(key.ID())); // EntityDemo = data != null ? new EntityDemo(data) : null; // if (EntityDemo != null) // { // AddEntity.Enqueue(EntityDemo); // } // } // } // return EntityDemo; //} public EntityDemo GetEntity(EntityDemoIdentity key) { EntityDemo EntityDemo = Get(Convert.ToInt32(key.ID())); if (EntityDemo == null) { Student student = new Student(); student.Id = Convert.ToInt32(key.ID()); student.Name = "TestDemo"; student.Record = 100; student.Sex = "测试"; EntityDemo = new EntityDemo(student); AddEntity.Enqueue(EntityDemo); } return(EntityDemo); }