Practical .NET Data Access Layer - 15

zhaozj2021-02-16  54

In the above schematic, step 7 pointing the Remoting Server is the host program.

Remoting Server wrapped in RemoteCustomer is the number of truly serving services.

According to the operation class.

The code listed below is implemented for this class:

Code 13: Remoting Call with Data Access Logic - 3, RemoteCustomer

Public Class RemoteCustomer: MarshalByrefObject

{

Public RemoteCustomer () {}

Public arraylist getAllCustomers ()

{

SqlConnection conn = new SQLCONNECTION

Helper.getApplicationSetting ("Connectionstring"));

// Get all Customer data via ObjectSpaces

Objectspace OS = New ObjectSpace

Helper.GetApplicationSetting ("mappingfile"), conn);

ObjectSet OST = Os.GetObjectSet (TypeOf (MyCustomer), "");

// Return to all Customer data in an ArrayList method

// Note: In the current version, the ObjectSet object is passed through Remoting with bugs.

ArrayList Al = New ArrayList (OST);

Return Al;

}

}

The author believes that after reading the code, some friends will have such questions:

The RemoteCustomer in code 13 is also analyzed in front of us.

Data Access Logic can work, although it is a layer of Remoting,

But the same is the same, is it possible to perform Customerdal_orm in code 11,12?

"Do you have a reorganization"?

The answer is yes!

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

(1) Do you still remember Dalbase in Code 9? As long as we make it inherit from MarshalByrefObject (originally the default object), you can "easily" to solve this problem! But don't be too happy, once this, all other Data Access Logic classes will have to accept this "extra gift" L, to know, after all, the chance to do Data Access Logic operation through Remoting is not a lot (generally through Business. Logic can solve the problem), such a "gift" is not what everyone can accept (this is the reason why the author is not in the Daf Solution)!

(2) In the CustomerDal_orm, please note: Don't forget to change the method name (because there is already a getAllCustomers method, although the return type is different, but any .NET's compiler is unable Distinguish this difference J)!

Next paragraph: http://www.9cbs.net/develop/read_article.asp? Id = 27559

转载请注明原文地址:https://www.9cbs.com/read-24093.html

New Post(0)