I have a large CSLA version 1 app that I would like to convert to version 4 to take advantage of WCF and WPF. I like the new (to me) project setup that allows easy switching between data access methods, so I set up my solution like this:
I am using the Encapsulated Invocation model. I created a simple class and it worked fine. My problems started when I tried converting more complex classes, particularly composite ones. For example, the system works with Point of Sale devices, so we have transactions. A transaction consists of a Header, one or more Items, and one or more Tenders. We have need to deal with the parts separately, so we have six classes (TransactionHeader, TransactionHeaders, TransactionItem, TransactionItems, etc.) We also have a composite Transaction class (which may or may not be what Rocky calls an object graph), which aggregates a TransactionHeader, a TransactionItems collection and a TransactionTenders collection.
In my data declarations for Transaction I have the following statements:
Private mTransactionHeader As TransactionHeader = TransactionHeader.NewTransactionHeaderChild()
Private mTransactionItems As TransactionItems = TransactionItems.NewTransactionItems()
Private mTransactionTenders As TransactionTenders = TransactionTenders.NewTransactionTenders()
Similarly, down in the DataPortal_Fetch routine I have:
.Connection = cn
.CommandType = CommandType.StoredProcedure
.CommandText = "USP_GetTransaction"
Using dr As New SafeDataReader(.ExecuteReader)
mTransactionHeader = TransactionHeader.GetTransactionHeaderChild(dr)
mTransactionItems = TransactionItems.GetTransactionItems(dr)
mTransactionTenders = TransactionTenders.GetTransactionTenders(dr)
Catch ex As Exception
CreateExceptionMessage(-3, "Operation failed.", ex)
My problem is that these classes are defined down in the MyLibrary.Net project, which references DataAccess. How do I reference them in my ITransactionDal class in DataAccess and the TransactionDal classes in DataAccess,Mock and DataAccess.SQL without creating a circular reference? Do I have to put them all in the same namespace rather than having separate DataAccess and MyLibrary namespaces? If so, what are the consequences of that?
I realize that I can put the data access code in my app class, just as it was in version 1, but I would prefer to stay with the flexibility of this solution layout, if possible. There's probably a simple answer, but I'm the only programmer at my company, so I don't have anyone to ask.
Copyright (c) Marimer LLC