1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 usingModel;6 usingSystem.Data.Objects.DataClasses;7 8 namespace Work9 {Ten      Public classDatabase<t>whereT:entityobject One     { A         protectedOfficeanywhereentities entities =Newofficeanywhereentities (); -  -         /// <summary> the         ///Add -         /// </summary> -         /// <param name= "T" ></param> -         /// <returns></returns> +          Public BOOLAdd (T t) -         { +Entities. AddObject (typeof(T). Name, T); A             returnSaveChanges () >0; at         } -  -         /// <summary> -         ///Execution -         /// </summary> -         /// <returns></returns> in         Private intSaveChanges () -         { to             Try +             { -                 returnentities. SaveChanges (); the             } *             Catch(Exception e) $             {Panax Notoginseng                 Throwe.innerexception; -             } the              +         } A  the         /// <summary> +         ///find an Object -         /// </summary> $         /// <param name= "Guid" ></param> $         /// <returns></returns> -         PrivateT Findbyguid (stringGuid) -         { theT t =NULL; -Entities. Createobjectset<t> (). ToList (). ForEach (p = {Wuyi                 if(p.entitykey.entitykeyvalues[0]. value.tostring () = =Guid) thet =p; -             }); Wu             returnT; -         } About  $         /// <summary> -         ///Delete -         /// </summary> -         /// <param name= "Guid" ></param> A         /// <returns></returns> +          Public BOOLDelbyguid (stringGuid) the         { -T t =Findbyguid (Guid); $             if(t!=NULL) the entities. DeleteObject (t); the             returnSaveChanges () >0; the         } the  -         /// <summary> in         ///Update the         /// </summary> the         /// <param name= "Guid" ></param> About         /// <param name= "Act" ></param> the         /// <returns></returns> the          Public BOOLUpdatebyguid (stringGuid, action<t>Act) the         { +T t =Findbyguid (Guid); - Act (t); the             returnSaveChanges () >0;Bayi         } the  the         /// <summary> -         ///List -         /// </summary> the         /// <returns></returns> the          PublicList<t>GetList () the         { the             returnEntities. Createobjectset<t>(). ToList (); -         } the     } the}
The database base class for the Entity framework for personal use