Setting Alias to multiple combined field

Posts   
 
    
mayvelous avatar
mayvelous
User
Posts: 5
Joined: 06-Feb-2007
# Posted on: 19-Feb-2007 04:55:06   

I like to set multiple fields combined alias such as the following.

storysection + \' - \' + storyhead AS storyname

I cannot find multiple combined field alias in the documentation. I only found single field alias under this section: "Generated code - Advanced filter usage, Adapter". I tried it as followed but it only setting to the last field and not both.

ResultsetFields fields = new ResultsetFields(1);
fields[0] = ArticleFields.StorySection + " - " + ArticleFields.StoryHead.SetFieldAlias("storyname");

So as expected, it throws out this error.

Cannot implicitly convert type 'SD.LLBLGen.Pro.ORMSupportClasses.Expression' to 'SD.LLBLGen.Pro.ORMSupportClasses.IEntityField2'. An explicit conversion exists (are you missing a cast?)

Could anyone point me to the right section from the documentation or help me sort out my syntax please?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 19-Feb-2007 06:18:12   

mayvelous, try this


// resulset
ResultsetFields fields = new ResultsetFields(1);

// define your new composed field via Expression
// Ref: GeneratedCode - Field expressions and aggregates
fields.DefineField(new EntityField2("storyname", (ArticleFields.StorySection + " - " + ArticleFields.StoryHead)), 0);

Hope helpful. wink

David Elizondo | LLBLGen Support Team
mayvelous avatar
mayvelous
User
Posts: 5
Joined: 06-Feb-2007
# Posted on: 19-Feb-2007 22:24:54   

Hey thanks so much. It's working now. I missed that section, thanks for providing the ref too. :-)

Cheers.