Conclusion

In this chapter, we created the business framework classes that enable data access. First, we updated our four base classes on which business objects will be built to include the idea of data access. Mostly, this revolves around the four DataPortal_xyz() methods :

  • DataPortal_Create()

  • DataPortal_Fetch()

  • DataPortal_Update()

  • DataPortal_Delete()

We then moved on to implement the client-side DataPortal that abstracts the use of remoting. The end result is that a configuration setting controls whether the actual data access code will run locally in the client process or remotely on another machine. The client-side DataPortal calls into a server-side DataPortal object that contains code to create new business objects if needed and to call the four DataPortal_xyz() methods.

We also created a second, transactional server-side DataPortal that runs within Enterprise Services (COM+). While Server.DataPortal is faster and can implement transactions using ADO.NET or stored procedures, the ServicedDataPortal.DataPortal runs within COM+, where we get the benefits of two-phase transactions. This is critical when updating two or more databases within a single transaction, but there's a performance penalty for its use.

Once the data access infrastructure was complete, we used it to create principal and identity objects that provide custom table-driven security. This security integrates into the .NET security framework and also integrates into our business framework, including handling impersonation so that our server-side data access code runs in the same user context as the client-side code.

Finally, we wrapped up by creating a couple of utility classes. The SafeDataReader class automatically handles null values in data from a database, converting any null values to an appropriate "empty" value. The NameValueList class is a base class that simplifies the creation of read-only name -value collection objects in our applications. We'll see how this is used in Chapter 7 as we create business classes for our example application.

This chapter completes the creation of the CSLA .NET framework. Through the remainder of the book, we'll be focusing on how to use the framework to create business objects and a variety of UIs for those objects including Windows Forms, Web Forms, and XML web services.



Expert C# Business Objects
Expert C# 2008 Business Objects
ISBN: 1430210192
EAN: 2147483647
Year: 2006
Pages: 111

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net