Back to Catalog
After the transformation of the storage interface, I always feel that there is a bad taste of the code, this taste stems from its DRP, that is, repeated code too much, that is, the asynchronous operation and synchronization operation is only different in insert,update and delete, the method of obtaining data is the same, so, I finally decided , the asynchronous interface is transformed to make it more reasonable, and the method is followed by the async suffix, which looks more like an async method, uh.
The modified asynchronous interface
/// <summary> ///Asynchronous Operation///basic Data Manipulation Specifications///agnostic to ORM Architecture/// </summary> /// <typeparam name= "TEntity" ></typeparam> Public InterfaceIrepositoryasync<tentity>whereTEntity:class { /// <summary> ///adding entities and committing to the data server/// </summary> /// <param name= "Item" >Item to add to Repository</param>Task Insertasync (TEntity item); /// <summary> ///remove entities and submit to data server///If the table has constraints, you need to delete the child table information first/// </summary> /// <param name= "Item" >Item to delete</param>Task Deleteasync (TEntity item); /// <summary> ///modifying entities and committing to a data server/// </summary> /// <param name= "item" ></param>Task Updateasync (TEntity item); /// <summary> ///Add Collection [Use this method when the number of collections is small, large collection uses Bulkinsert]/// </summary> /// <param name= "item" ></param>Task Insertasync (ienumerable<tentity>item); /// <summary> ///Modify Collection [Use this method when the number of collections is small, large collection using Bulkupdate]/// </summary> /// <param name= "item" ></param>Task Updateasync (ienumerable<tentity>item); /// <summary> ///Delete Collection [with this method when the number of collections is small, large collections using bulk Delete]/// </summary> /// <param name= "item" ></param>Task Deleteasync (ienumerable<tentity>item); /// <summary> ///Bulk Add, add before you can remove the self-increment property, default does not remove/// </summary> /// <param name= "item" ></param> /// <param name= "isremoveidentity" ></param>Task Bulkinsertasync (ienumerable<tentity> item,BOOLisremoveidentity); /// <summary> ///Bulk Add/// </summary> /// <param name= "item" ></param>Task Bulkinsertasync (ienumerable<tentity>item); /// <summary> ///Batch Update/// </summary> /// <param name= "item" ></param>Task Bulkupdateasync (ienumerable<tentity> item,params string[] fieldparams); /// <summary> ///Bulk Delete/// </summary> /// <param name= "item" ></param>Task Bulkdeleteasync (ienumerable<tentity>item); }
And the original iextendrepository synchronization to inherit synchronous and asynchronous two storage interfaces
On the call, developers are more aware of whether they are using synchronous or asynchronous methods
Back to Catalog
EF Architecture ~ef Asynchronous Transformation ~ Warehousing Interface Transformation ~ Cont.