EF Architecture ~ef Asynchronous Transformation ~ Warehousing Interface Transformation ~ Cont.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.