New calculated field

Posts   
 
    
e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 10-Feb-2010 00:08:35   

Hi i have 3 tables in the following structure:

class table: classid courseid sectionid

course table: courseid coursename

section table sectionid sectionname

i want to create a classcollection and bind it to a dropdown menu, having coursename-sectionname (coursename dash secitonname) as the data text field and classid as the value.

it is like adding a new calculated field into the class collection. what would be the easiest way to accomplish this?

thanks in advance -shane

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 10-Feb-2010 03:16:36   

Just create a custom property on your ClassEntity. You can do this in a parital class or in CUSTOM_USER_CODE_REGION:

namespace <YourNameSpace>.EntityClasses
{
     public partial class ClassEntity
     {
          public string CourseSectionName
          {
               get
               {
                    string toReturn = string.Empty;
                    
                    if (Course != null)
                    {
                         toReturn += Course.CourseName;
                    }

                    if (Section != null)
                    {
                         toReturn += Section.SectionName;
                    }

                    return toReturn;
               }
          }
     }
}

Then just use such property in your databinding.

David Elizondo | LLBLGen Support Team
e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 10-Feb-2010 17:54:21   

thank you. that worked as expected.

is there a way to accomplish this by creating a typed list through the designer? a view can do that using expressions, cant figure out if typed list designer can also do it.

There is the custom property in designer but i dont really know how to use it. tried a couple combination with no luck. is it possible to create a custom property called ClassName that will be Course.Name + Section.Name ?

thank you -shane

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 11-Feb-2010 02:49:05   

e106199 wrote:

is there a way to accomplish this by creating a typed list through the designer? a view can do that using expressions, cant figure out if typed list designer can also do it.

No, no in typed lists. The only options are: - Custom property on Entity class - DynamicLists - TypedViews (mapped from a custom database view)

e106199 wrote:

There is the custom property in designer but i dont really know how to use it. tried a couple combination with no luck.

No. Custom properties are addition info you want in your entity/view

e106199 wrote:

is it possible to create a custom property called ClassName that will be Course.Name + Section.Name ?

No, it is possible just in the ways I mentioned above.

David Elizondo | LLBLGen Support Team
e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 11-Feb-2010 05:01:57   

i get it. thank you.