Combat. Net data Access Layer-15

Source: Internet
Author: User
Access to the diagram above, step 7 points to the remoting server is the host program,

And the RemoteCustomer of remoting server is the number of real service providers.

According to the Operation class.

The code listed below is implemented as part of the class:



Code 13: Use the data Access logic to make remoting calls –3,remotecustomer



public class Remotecustomer:marshalbyrefobject

{

Public RemoteCustomer () {}



Public ArrayList getallcustomers ()

{

SqlConnection conn = new SqlConnection (

Helper.getapplicationsetting ("ConnectionString"));



Get all customer data through objectspaces

ObjectSpace OS = new ObjectSpace (

Helper.getapplicationsetting ("MappingFile"), conn);



Objectset ost = OS. Getobjectset (typeof (MyCustomer), "");



Return all customer data in ArrayList mode

Note: In the current release, the Objectset object is passed through the remoting with a Bug

ArrayList al = new ArrayList (OST);



Return al;

}

}































































The author believes that after reading the code, certain friends will have the question:

The RemoteCustomer in code 13 is the one we analyzed earlier.

The work that Data Access logic can accomplish, although it is separated by a layer of remoting,

But essentially the same, can not be with the code 11,12 in the Customerdal_orm

An "effective reorganization"?

The answer is YES!



However, we still need to do two very simple operations:

(1) Do you remember the Dalbase in code 9? As long as we make it inherit from MarshalByRefObject (formerly the Default object), we can "easily" solve this problem! But don't be too early, once again, all the other data access logic classes will have to accept this "unwanted gift" L, and you know, after all, there's not a lot of access to the data access logic via remoting (typically through business Logic to solve the problem), such a "gift" is not everyone can enjoy (this is also the author did not in the DAF solution the reason for such a realization)!

(2) Incorporate the above RemoteCustomer code into the customerdal_orm, but note: Do not forget to change the method name (because there is already a getallcustomers method exists, although the return type is different, but any. NET under the compiler are unable to distinguish between the J of this difference!



Next paragraph: http://www.csdn.net/develop/Read_Article.asp?id=27559


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.