Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> Convert String fields' value to UPPER
 

Pages: 1
LLBLGen Pro Runtime Framework
Convert String fields' value to UPPER
Page:1/1 

  Print all messages in this thread  
Poster Message
sekorev
User



Location:

Joined on:
16-May-2008 12:28:03
Posted:
11 posts
# Posted on: 23-Jun-2008 10:11:38.  
Hi,

Lets say that i have a car entity.

Code:

txtModel.Text = "Audi";
txtYear.Text = "1983";
txtSubject.Text = "this is An Info abouT the CAr. ";
CarEntity car = new CarEntity();

car.Model = txtModel.Text;
car.Year = txtYear.Text;
car.Info = txtSubject.Text ;

car.Save();


what i want to do is
whatever the inputs are
convert strings to uppercase before ( or just before) Save() function. ( And also i want to replace some characters like ö >> oe , ü >> ue in german ) is there an easy way to do?

After persisting object in db.
MODEL = "AUDI"
YEAR = "1983"
INFO = "THIS IS AN INFO ABOUT THE CAR"

i use SelfServicing model.

thank in advance
  Top
goose
User



Location:
Central America
Joined on:
06-Aug-2007 18:21:05
Posted:
385 posts
# Posted on: 23-Jun-2008 19:47:37.  
You could use one of those methods:


Code:

// this is called when a value is set
public partial class CarEntity
{
    protected override void PreProcessValueToSet(IEntityField2 fieldToSet, ref object valueToSet)
    {
        base.PreProcessValueToSet(fieldToSet, ref valueToSet);

        // set to UPPERCASE
        if (valueToSet != null)
        {
            if (fieldToSet.Name == CarFields.Model.Name || fieldToSet.Name == CarFields.Info.Name)
            {
                valueToSet = (string)((string)valueToSet).ToUpper();
            }
        }
    }
    
    
    // this is called right before the entity is saved
    protected override void OnBeforeEntitySave()
    {
        // set to UPPERCASE
        Model = Model.ToUpper();
        Info = Info.ToUpper();

        
        base.OnBeforeEntitySave();
    }
}


gansodesoya  Top
sekorev
User



Location:

Joined on:
16-May-2008 12:28:03
Posted:
11 posts
# Posted on: 23-Jun-2008 20:20:29.  
Hi goose,

I have nearly 60 entities, it is really hard to rewrite them by hand.
whenever an entity has string values, automatically convert to upper.
Is there any way to do it using templates or some other stuff?
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37411 posts
# Posted on: 23-Jun-2008 20:48:00.  
Override PreProcessValueToSet in a partial class of CommonEntityBase Regular Smiley (that will take 1 override Regular Smiley)

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



Location:

Joined on:
16-May-2008 12:28:03
Posted:
11 posts
# Posted on: 23-Jun-2008 21:01:38.  
Hi Otis,

i am too newbie to find it.

in the generated project CommonEntityBase.cs , within the class

protected override void PreProcessValueToSet()
        {

        }

Error    1    'light.EntityClasses.CommonEntityBase.PreProcessValueToSet()': no suitable method found to override    C:\Projects\lightNET\light\EntityClasses\CommonEntityBase.cs

i appreciate if you show.
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37411 posts
# Posted on: 23-Jun-2008 22:22:41.  
It's a method in EntityBase/EntityBase2:
Code:

/// <summary>
/// Method which is meant to be overriden to pre-process a value right before it is set as a field's new value. In general you don't need to override
/// this method. By default it's a no-op.
/// </summary>
/// <param name="fieldToSet">The field to set.</param>
/// <param name="valueToSet">The value to set.</param>
protected virtual void PreProcessValueToSet( IEntityField2 fieldToSet, ref object valueToSet )
{
    // nothing
}


so you should be able to override it.


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



Location:

Joined on:
16-May-2008 12:28:03
Posted:
11 posts
# Posted on: 24-Jun-2008 13:38:34.  
Hi,

I dont know how ,the code works now.
Thanks all

Quote:


in the generated project CommonEntityBase.cs , within the class

protected override void PreProcessValueToSet()
        {

        }

Error    1    'light.EntityClasses.CommonEntityBase.PreProcessValueToSet()': no suitable method found to override    C:\Projects\lightNET\light\EntityClasses\CommonEntityBase.cs

i appreciate if you show.
  Top
Pages: 1  


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

Version: 2.1.12172008 Final.