Can't find the Business Objects in the PTracker Example

Can't find the Business Objects in the PTracker Example

Old forum URL: forums.lhotka.net/forums/t/4872.aspx


Crestview posted on Tuesday, May 20, 2008

Can anyone tell me where the classes that define the business objects are located ?  I have looked in the PTracker.dal and PTracker.library projects but I can't find them.  They reason I am looking is to help understand how this framework establishes and manages the connection to the SQL Server Database.  I haven't been able to find the connection logic either.

Thanks for any direction you can provide.

justin.fisher replied on Tuesday, May 20, 2008

They actually are in the library project.  It may be a bit confusing since the example is frequently using LINQ to SQL instead of the ADO.Net to make the calls.

If you aren't familar with LINQ there is a pretty good set of introduction web casts on MSDN.  You can register and view one here.

RockfordLhotka replied on Tuesday, May 20, 2008

When using LINQ to SQL the database connection is typically managed by the L2S data context object. That context class is defined in the DalLinq project, and was created by Visual Studio.

In the Library project you'll see the DataPortal_XYZ methods. They are required by CSLA and are the points at which your business object must create/fetch/update its data using the DAL. Notice that this is the point at which the data context is used.

Csla.Data.ContextManager is a CSLA .NET type that helps you manage the database connection contained within the data context. When using TransactionScope you must make sure to open and reuse one single database connection and ContextManager makes this relatively easy when using L2S.

There's also Csla.Data.ConnectionManager that does the same thing for any raw database connection object (like a SqlConnection).

Copyright (c) Marimer LLC