Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> Custom TypedView Code
 

Pages: 1
LLBLGen Pro Runtime Framework
Custom TypedView Code
Page:1/1 

  Print all messages in this thread  
Poster Message
DaveR
User



Location:

Joined on:
15-Jun-2004 16:37:10
Posted:
43 posts
# Posted on: 08-Nov-2005 22:40:15.  
Are custom code regions in TypedView classes supported?

We're trying to add code in the usual way, i.e.

but when we regenerate the code, these regions are overridden.

Code:
#region Custom TypedRow code
// __LLBLGENPRO_USER_CODE_REGION_START CustomTypedRowCode
// __LLBLGENPRO_USER_CODE_REGION_END        
#endregion


Using Version 1.0.2004.2 July 25th, 2005.
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37804 posts
# Posted on: 08-Nov-2005 23:03:08.  
You added code to a region in the generated code or did you add the region as well to the generated code?

Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
DaveR
User



Location:

Joined on:
15-Jun-2004 16:37:10
Posted:
43 posts
# Posted on: 09-Nov-2005 00:14:27.  
We added a new #region to the code, outside of existing regions, following the example of the entity classes.

We tried different permutations, i.e. putting inside existing region, outside any region, but the custom code is always overwritten.
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37804 posts
# Posted on: 09-Nov-2005 10:08:31.  
You can't add a region into the code, that's not how it works. The template engine sees a region definition in the template, then reads the region from the code file that already exists, and merges that into the output generated at the spot of the region read in the template (so you can have scoped regions). So if you add a region to the generated code, that's not helping.

You should add the region to the generated code by adding a usercoderegion definition to an include template, then bind that template to the include template ID for typed views. The usercode region then will end up in the template, and it will thus work. Regular Smiley


Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
pg
User



Location:
Athens, Greece
Joined on:
19-Oct-2005 14:28:33
Posted:
13 posts
# Posted on: 11-Nov-2005 16:00:51.  
But why isn't there already any custom code region in typed views, as it is for example in entity and collection classes?

Since "Custom Code Regions" are very usefull in Entities and Collections, I was wondering if it is going to be added in typed Views in a future realease.
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37804 posts
# Posted on: 12-Nov-2005 18:00:27.  
Which regions do you want us to add and to which classes/routines precisely? I'd prefer if you also state an example for the region usage. Regular Smiley

Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
pg
User



Location:
Athens, Greece
Joined on:
19-Oct-2005 14:28:33
Posted:
13 posts
# Posted on: 13-Nov-2005 13:22:03.  
We want to add custom made columns to a view. For example, lets say that we have a view that returns a patient's First Name, Last Name and Middle Name and we want to have extra columns based on those three like: FullNameInverse, FullName, ShortName and ShortNameInverse.

It would be much more flexible to be able to add this columns in the typedRow class instead of trying to build the column using SQL directly in the Database View.

For example the following whould be very usefull in a TypedRow class:

// __LLBLGENPRO_USER_CODE_REGION_START CustomTypedRowCode

public string PatientNameInverse
        {
            get    
            {
                if (0 == this.PatientLastName.Length && 0 == this.PatientFirstName.Length && 0 == this.PatientMiddleName.Length)
                    return "";

                return string.Format("{0}, {1} {2}", this.PatientLastName, this.PatientFirstName, this.PatientMiddleName).Trim();
            }
        }

and

public string PatientName
        {
            get    
            {
                if (this.PatientMiddleName.Length > 0)
                    return string.Format("{0} {1} {2}", this.PatientFirstName, this.PatientMiddleName, this.PatientLastName).Trim();
                else
                    return string.Format("{0} {1}", this.PatientFirstName, this.PatientLastName).Trim();
            }
        }

// __LLBLGENPRO_USER_CODE_REGION_END

Then in typed views we might need to add custom fill methods that use specific criteria. Lets say that we have a view that returns medical reports and we want to build a custom method that would return draft reports. We want to put that method in the typedView class because we use it in different parts of our application.

The folowing would be usefull:

// __LLBLGENPRO_USER_CODE_REGION_START CustomTypedViewCode

public bool GetReportsDrafts(int siteID, int accountID, Role userRole, int rowsToReturn, ISortExpression sortClauses)
        {
            IPredicateExpression selectFilter = BuildReportsDraftsFilter(accountID, userRole, siteID);
            return Fill(rowsToReturn, sortClauses, true, selectFilter);
        }

......

private IPredicateExpression BuildReportsDraftsFilter(int accountID, Role userRole, int siteID)
        {
            
            IPredicateExpression filter = new PredicateExpression(PredicateFactory.CompareValue(ExplorerFieldIndex.ReportStatus, ComparisonOperator.Equal, ReportStatus.Draft));

.......

            return filter;
        }

// __LLBLGENPRO_USER_CODE_REGION_END

Collections already support this functionallity. Why not TypedViews as well?

What we do now is, add this custom code regions in TYpedView and TypedViewRow and do the merge manually after code regeneration Dissapointed
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37804 posts
# Posted on: 13-Nov-2005 14:48:10.  
So basicly that's the same as the regions found in a typed list. Be aware that to be able to use new properties best, it's key datacolumns are added to teh underlying datatable. The typedlist already has regions for doing so in buildresultset.

For the code in the CustomTypedViewCode region you posted, you can use an include template, which generates a usercoderegion in every typed view. You can then add the code to that usercoderegion, or you can also generate the code you want to add to the view via the include template (for example, if the code is used in every typedview).

I'll update the typedview template with regions ala the typedlist, (and also the row classes so they're extensible as well).


Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Rogelio
User



Location:
Panama, Panama
Joined on:
29-Mar-2005 02:57:36
Posted:
221 posts
# Posted on: 13-Nov-2005 15:08:38.  
Hi,

About adding custom code (that return typedview) inside the typedview class, be aware that this approach will not work if you decide to use your app. with a remote-business server that will supply service to your GUI tier. It is better to have a class service that has method to return the typedview with the data that you need.

  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37804 posts
# Posted on: 15-Nov-2005 12:45:20.  
These regions have been added to the template, and are available in the next build.

Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.