CSLA .NET

From Rockford Lhotka's Expert C# 2008 and VB 2008 Business Objects books

CodeSmith C# Templates on Codeplex

This post has 37 Replies | 8 Followers

Top 500 Contributor
Posts 13
czuvich replied on Thu, Jun 26 2008 2:50 PM

Great work on the templates; however, I'm wondering you didn't incorporate the private backing field to all properties?

Top 25 Contributor
Posts 184
rasupit replied on Fri, Jun 27 2008 6:03 AM
czuvich,
There is no specific reason why I chose to use manage field over private backing field.  Do you see an advantage one over the other?

Ricky
Top 10 Contributor
Posts 1,244

For regular CSLA I am not sure it makes a difference. Need to read the book when it comes out though.

But for CSLA Lite - (Silverlight) - I think it works best with managed fields.

Joe

 

Top 500 Contributor
Posts 13
czuvich replied on Fri, Jun 27 2008 10:45 AM
It's not a big deal... If I am not mistaken there's a performance boost with using the backing field in regular CSLA. Thanks for the reply. Good work!
Top 25 Contributor
Posts 184
rasupit replied on Sat, Jun 28 2008 6:25 AM
@Joe: Yes I remember Rocky mention about not having additional serialization code when using field manager.

@czvich:
To modify the template to use private backing is quite easy actually.
1. just need to add (in PropertiesMethods.inc) private field and use it in getter and setter. 
2. search and replace and LoadProperty and ReadProperty methods. I think all of them are in DataPortalxxx area

I'll leave that to anybody that want to squeeze a few extra juice out Cool [H]
Ricky


Top 50 Contributor
Posts 134
reagan123 replied on Wed, Sep 10 2008 7:52 AM
I'm about to make the jump to 3.5.  Great work on the C# templates.  Does anyone know if anyone did the VB ones... or atleast started them?

Thanks for any info :)
Top 75 Contributor
Posts 86
Patrick replied on Wed, Sep 17 2008 5:22 AM
Patrick:
I really like the ability to generate the code from XML with your templates.
Thanks for all your effort,
Patrick

Hi Ricky,

the old release of the templates for CSLA.NET 2.0 contained these files
CslaXml.cst
Csla.cst
CslaProject.xsd
MySample.xml

The CslaXml seems to work with the sample file, the Csla.cst has an error
100,26): error CS0117: 'CodeSmith.Csla.TemplateBase.CodeGenerationMethod' does not contain a definition for 'SplitBase'

It might be worth porting them to the new templates as many new users might not even know they exist and then think they have to create each class by itself... and miss out on the option to define an xml file for code generation.

Thanks,
Patrick
Top 150 Contributor
Posts 45
k2so replied on Wed, Sep 17 2008 9:15 AM
great work! let me try it out

thx
so.
Top 25 Contributor
Posts 184
rasupit replied on Wed, Sep 17 2008 5:46 PM
Patrick:
the old release of the templates for CSLA.NET 2.0 contained these files
CslaXml.cst
Csla.cst
CslaProject.xsd
MySample.xml


I went through some major rewrite to remove the rendering dependency from CodeSmith Table Schema to CSLA metadata so that these template can support other data source such as XML.

Thanks for the reminder. I'll work on upgrading these templates.  There are others I think still left behind: EditableSwithable and NameValueList comes to mind.
Top 75 Contributor
Posts 86
Patrick replied on Wed, Sep 24 2008 2:54 PM
Hi Ricky,

just a quick question.

Why did you name the partials methods with the class name embedded:
        partial void OnProjectRootInfoListFetching(ref bool cancel);
        partial void OnProjectRootInfoListFetched();

Instead of just:
        partial void OnFetching(ref bool cancel);
        partial void OnFetched();

Thanks,
Patrick
Top 500 Contributor
Posts 26
zinovate replied on Wed, Sep 24 2008 5:44 PM
Nice call on XML Support. I'd love to Gen from a EDM or Linq2SQL model. Not a bad "CSLA" designer especially with the EF features.
Not Ranked
Posts 9
hampole replied on Wed, Sep 24 2008 6:52 PM
I have been using CodeSmith templates V2.0 for CSLA2.0. Now I have switched to CSLA3.5 and trying to use 3.5 templates. I successfully generated the objects for my tables but when I try to build, I get the following errors.
The type or namespace name 'Dal' could not be found.

The code snippet is as follows.
var mgr = ContextManager<Dal.RMDBDataContext>

I am not too familiar with the new version. Please let me know how to resolve this. I appreciate your help.

Ravi
Top 75 Contributor
Posts 107

Hi hampole

Have a look at the PTracker example. Look in the ProjectTracker.DalLinq project in the solution.

From project.cs in Library

      using (var ctx = ContextManager<ProjectTracker.DalLinq.PTrackerDataContext>.GetManager(ProjectTracker.DalLinq.Database.PTracker))
      {
        // get project data
        var data = (from p in ctx.DataContext.Projects <--
                    where p.Id == criteria.Value
                    select p).Single();
        LoadProperty<Guid>(IdProperty, data.Id);
        LoadProperty<string>(NameProperty, data.Name);
        LoadProperty<SmartDate, System.DateTime?>(StartedProperty, data.Started);
        LoadProperty<SmartDate, System.DateTime?>(EndedProperty, data.Ended);
        LoadProperty<string>(DescriptionProperty, data.Description);
        mTimestamp = data.LastChanged.ToArray();

        // get child data
        LoadProperty<ProjectResources>(ResourcesProperty, ProjectResources.GetProjectResources(data.Assignments.ToArray()));
      }

This links to PTracker.dbml in DalLinq

database markup language (.dbml) metadata file.

 

Not Ranked
Posts 9
hampole replied on Thu, Sep 25 2008 12:43 PM
Thanks for your response. I looked at the PTracker project and still I am confused. I have all the tables and the CRUD procedures in SQL server. Do I need to create dbml file with all the meta data. Is there any tool to do that? Please help.

Thanks,
Ravi

Top 75 Contributor
Posts 107

Once you have your Data Sources connected, you should be able to drag everything you need from the Data Sources window.

Yes you will need to add a new dbml object to your project.

 

Page 2 of 3 (38 items) < Previous 1 2 3 Next > | RSS

Please contact Magenic for your .NET consulting
and CSLA .NET mentoring needs.
Please consider making a donation to help support the ongoing development of CSLA .NET.

Make donation through PayPal - it's fast, free and secure!
Why donate?
Copyright (c) 2006-2010 Marimer LLC. All rights reserved.
Email admin@lhotka.net for support.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems