EntityFramework underlying operation encapsulation (3)

Source: Internet
Author: User
I talked about the encapsulation of several classes. This time we will talk about how to use it. In the actual process, how can we describe that we are missing the coding? For example, if we need a class to implement operations on a table, we only need to inherit from our Base class. UsingSystem; usingSystem. Collections. Generic; usingSystem

I talked about the encapsulation of several classes. This time we will talk about how to use it. In the actual process, how can we describe that we are missing the coding? For example, if we need a class to implement operations on a table, we only need to inherit from our Base class. Using System; using System. Collections. Generic; using System

I talked about several typesEncapsulationThis time, let's talk about how to use it.

In the actual process, how can we describe that we are missing the coding?

For example, we need a class to implementOperation, We only need to inherit from our Base class.

using System;using System.Collections.Generic;using System.Linq;using System.Text;using NOAS.PublicOpinionMonitor.Access.Common;using NOAS.PublicOpinionMonitor.ENTITY;namespace NOAS.PublicOpinionMonitor.Access{    public class ProxyDAL : AccessBase
 
      {        public ProxyDAL()            : base(strTableName:"t_po_monitor_proxy",ColumsName:@" [monitorid]                                                                  ,[monitor_name]                                                                  ,[tkwid]                                                                  ,[monitor_stardate]                                                                  ,[monitor_enddate]                                                                  ,[monitor_datetype]                                                                  ,[monitor_interval]                                                                  ,[data_begindate]                                                                  ,[data_enddate]                                                                  ,[exec_datetime]                                                                  ,[monito_days]                                                                  ,[updatedate]                                                                  ,[status]")        {        }        public List
  
    getAllMonitorProxy()         {           return getListByWhere(string.Empty);        }            }}
  
 
What I insist on is to do my own things. Therefore Bottom LayerWhen the architecture is involved, each class can only OperationCorresponding table. This makes our code clearer.

It is easier to use the service layer.

using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace NOAS.PublicOpinionMonitor.BIZ{    public class ProxyBLL    {        public int addMonitorProxy(ENTITY.t_po_monitor_proxy proxyEntity)         {            new NOAS.PublicOpinionMonitor.Access.ProxyDAL().addEntity(proxyEntity);            return proxyEntity.mproxyid;        }        public int updateMonitorProxy(ENTITY.t_po_monitor_proxy proxyEntity)        {            new NOAS.PublicOpinionMonitor.Access.ProxyDAL().updateEntity(proxyEntity);            return proxyEntity.mproxyid;        }    }}

From here, I also like design and architecture. The architecture makes programming more beautiful. Think more, do more, and read more. Make our code clearer.

We are not coders. We are city fighters.

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.