Hi,
I read some discussion on the forum and tried to download some code samples. I have been using my own DAL in the past for my DNN (Dotnetnuke) applications since DNN DAL is missing the nullable integer, datetime etc. Also I do not like retyping a tedious DAL. Now I am charmed by LINQ and I used the PLINQ of CodeSmith. I think it is not really a Business Layer, but more a Data access layer.
I miss for a web application some things:
I think 1. and 4 are most important for me. Is CSLA.NET then something for my store project?
Any help appreciated. In particular is there is some sample project with code smith template that shows the implementation of 1 and 4.
J.
1) If you are using the data portal, you can do caching (using static fields or System.Web.Caching) in your object's factory methods. That is a powerful technique that works even if the UI technology (DNN) doesn't support caching.
4) This is exactly how CSLA is designed to work. The preferred model for building a CSLA object is to implement static factory methods that use the data portal to create and populate the object instance.
If you are totally fixated on PLINQ though, and it sounds like you are, then I don't know if CSLA will be a great fit for you. PLINQ (or LINQ to Objects in general) is about reshaping sets of data objects into other data objects. And that's a fine thing.
But it isn't what CSLA is about. CSLA is about creating objects based on behavior, not data. While reshaping them is fine to an extent, the reality is that if you are reshaping a CSLA object model (beyond sorting and filtering of collections), then you just have a broken object model and you should really rethink your object design...
It sounds to me like you need to step back and decide whether you want data-centric objects or behavior-centric objects. If you want data-centric, CSLA isn't a great fit. If you want behavior-centric, then CSLA should be a great fit.
Dear Rocky,
Seems that point 4) is in CSLA. Where can I catch up information on how to generate a CSLA for my MSSQL database objects? I would like to see some samples of how the generated logic looks like. I am also interesting to know if somebody can generate a DAL for me or show me some additional guidance in using the CSLA codesmith templates.
You mention filtering. In LINQ this can easily be done by passing an additional WHERE clause to the database server so that the data returned is limited ('filtered') by this WHERE clause. I think the CSLA objects are filtered on the web server ? That makes is heavier than using LINQ?
Any help is appreciated.
Best Regards,
J.
Joe’s reply is very good. Don’t confuse CSLA with an
ORM – it is not an ORM. CSLA helps you build a distributed business
layer, not a data access layer.
Also, you say that filtering can be done in LINQ by passing a
where clause to the database. Don’t confuse LINQ with LINQ to SQL. LINQ
to SQL is one tiny part of LINQ, and is actually something that Microsoft has
indicated is not on the strategic path.
Yes, L2S allows you to filter data in a query, but any data
access technology allows you to do that. CSLA is not a data access layer, but
it does provide a rich business layer (or more accurately helps you create one).
You could do filtering in the business layer, or even the UI layer (some data
grid controls do it). And sometimes that makes sense, especially for smart
client apps (Silverlight, WPF, etc). CSLA also allows you to push the filtering
concept into the data access layer, and sometimes that makes sense, especially
for web apps, or any app where there are thousands of rows of data.
The point is that there’s flexibility so you can choose
the right answer for your particular situation and application.
Rocky
Hi,
Thanks for the quick replies. I have ordered the book at bol.com since CSLA seems interesting. I have seen you use the Catalook Dotnetnuke store for paperbacks. I want to use CSLA for my DNN shopping engine I am creating. I have my own CodeSmith that generates stored procedures and DAL (so is it called in DNN). I have not yet a code template for Caching and static calls. For that reason I am looking what can be interested. In particular since I am also using webservices and in the future Silverlight. It would be easier to judge if some code samples would be present for a database.
Any help appreciated.
J.
The ProjectTracker application is the primary reference
application for CSLA .NET, and it uses a database (via LINQ to SQL at the
moment) for a data access layer.
Rocky
StoreIntegrator:I have seen you use the Catalook Dotnetnuke store for paperbacks. I want to use CSLA for my DNN shopping engine I am creating.
In my view, there's certainly a market opportunity for you - the Catalook store is overly complex, really hard to configure, harder to style and doesn't have good support for selling downloadable content.
On the other hand, it is really cheap. Unfortunately in this case I think I got what I paid for :(
Hi Rocky,
Currently no software download is in my roadmap. At the time I have resources for that I will contact you. It is interesting that you talk about LinQ to SQL project "The ProjectTracker application is the primary reference application for CSLA .NET, and it uses a database (via LINQ to SQL at the moment) for a data access layer." Can I download that to see how that uses a static DAL, or it that also not having it?
J.
I don’t know what you mean by “static DAL”.
ProjectTracker uses the DataPortal_XYZ model and in the
DataPortal_XYZ methods it uses L2S to interact with the database. So yes, if
you download ProjectTracker and look at the code you’ll see how to use
L2S to create a DAL behind CSLA objects.
Also Chapter 18 of the 2008 book discusses this, and other data
access options supported by CSLA .NET.
Rocky
Hi,
I have not received your book yet. I think this week it will arrive.
With static I mean:
In DNN you use to write:
AddressController addressController = new AddressController()
Address address = addressController.GetAddressById(1)
Static is:
Address address = AddressController.GetAddressById(1)
Same for a CRUD:
AddressController.GetAddressById(1)
AddressController.Update(address)
AddressController.Delete(1)
AddressController.Create(address)
AddressController.List()
J.
CSLA requires the use of factory methods. Well, that’s not
entirely true, but it encourages the use of factory methods.
You can create your factory methods as static methods –
which is what I usually do.
var customer = Customer.GetCustomer(123);
Or you can create factory classes, with factory methods
var factory = new CustomerFactory();
var customer = factory.GetCustomer(123);
Either approach is fine. The first one is simple and easy to implement.
The second enables the use of dependency injection and other “fancy”
patterns – but honestly there’s little value to taking that
approach since the typical factory method just invokes the data portal, so
there’s already a great deal of abstraction involved, and adding more
abstraction offers little value.
Rocky
From: StoreIntegrator
[mailto:cslanet@lhotka.net]
Sent: Sunday, May 10, 2009 4:34 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] RE: RE: Is CSLA.NET useful for my project?
Hi,
I have not received your book yet. I think this week it will arrive.
With static I mean:
In DNN you use to write:
AddressController addressController = new AddressController()
Address address = addressController.GetAddressById(1)
Static is:
Address address = AddressController.GetAddressById(1)
Same for a CRUD:
AddressController.GetAddressById(1)
AddressController.Update(address)
AddressController.Delete(1)
AddressController.Create(address)
AddressController.List()
J.
Copyright (c) Marimer LLC