Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> varchar fields and max length
 

Pages: 1
LLBLGen Pro Runtime Framework
varchar fields and max length
Page:1/1 

  Print all messages in this thread  
Poster Message
obzekt
User



Location:

Joined on:
29-Apr-2004 18:18:59
Posted:
49 posts
# Posted on: 23-Jun-2005 16:14:06.  
Hello. I would like to ask if there is a method to truncate string fields. If for example you have a Person.LastName field that is defined as varchar(30) and you attempt to set the PersonEntity.LastName property to a longer value, then an ArgumentOutOfRange exception is thrown.

Most of the time that is what we need, but in some cases we may prefer to just store as much as we can, truncating the end. Here's what I currently do:

Code:

int maxlen = person.Fields[(int)PersonEntityFieldIndex.LastName].SourceColumnMaxLength;
person.LastName = (name.Length > maxlen) ? name.Substring(0, maxlen) : name;


It would be nice to have that an option on that field, and have the framework truncate the string on the developer's behalf.

Frans, what is your opinion on this? Is that something we can expect added in the future?
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37870 posts
# Posted on: 24-Jun-2005 12:38:20.  
I typically find this something which should be done in a rule defined in the BL. Though of course this rule could be added/executed from the framework. For 2.0 a rule-framework is planned, so I'll add it to that list.

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



Location:

Joined on:
17-Dec-2006 16:16:10
Posted:
11 posts
# Posted on: 17-Dec-2006 16:28:46.  
Hi there,

I'm using 2.0.0.0 and get exactly the error described by other user.
Specifically, my sql server pads the strings with spaces and i would expect this exception to occur quite often, when users inserts characters in a field without clearing it to the end.

When you speak of a rule-framework (which I hope was implemented?), how do i apply it? Just a reference to a topic in the help file will be appreciated. I can't seem to locate it.


Otis wrote:
I typically find this something which should be done in a rule defined in the BL. Though of course this rule could be added/executed from the framework. For 2.0 a rule-framework is planned, so I'll add it to that list.

  Top
Chester
Support Team



Location:
Chicago, IL USA
Joined on:
15-Jul-2005 22:38:41
Posted:
223 posts
# Posted on: 17-Dec-2006 19:24:24.  
Check out the documentation on Validation and Validators.
(Using the generated code -> Field validation and entity validation)


  Top
Pages: 1  


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

Version: 2.1.12172008 Final.