Welcome to the CodeSmith Community!

Re: get additional column in entity datasource

.netTiers

A description has not yet been added to this group.

get additional column in entity datasource

  • rated by 0 users
  • This post has 4 Replies |
  • 4 Followers
  • Hi,

    i have two tables named as Project and ProjectCost, ProjectCost has foreign key named as PrjKey from Project table.

    while showing the ProjectCost in the entitygridview i also want to show the PrjName from the Project table in the grid.

    i am using  ProjectCostDataSource.GetAll() Method and i also changed stored procedure ProjectCost_Get_List selection columns joining with the Project table. 

    can anyone help me how to show the PrjName in the entitygridview.  

    i am very new to .NetTiers 

     

  • Hello,

    Did you get this figured out?

    Thanks
    -Blake Niemyjski

    Blake Niemyjski
    CodeSmith Tools, LLC. Software Development Engineer
    Blog: http://windowscoding.com/blogs/blake/
    .NetTiers team | Visit http://www.nettiers.net

  • Hi,

    i had a similar problem. I did it the hard way, which means in every layer (SQL-DAL-Entity (you even need to extend the ColumnEnum) i added a new column, i changed all select statements in the xml files regarding this entity and added the row to read the field explicitly in the section with the datareader.

    This was sure a lot of work, but at the end of the day you have all the power of SQL to get whatever field or calculation you may need, and its available in your entity/gui.

    Once you have the property in the entity filled you can use it like any other bound field.

     

  • I'm not familiar with the default netTiers controls as i wrote my own user control templates. However i'm hoping this may be of some help anyway.

    In my setup i would edit the ProjectCost entity and add the following code

    /// <summary>
    /// Gets the PrjName property of the ProjectIdSource .
    /// </summary>
    [Description(@""), Bindable(BindableSupport.Yes)]
    public string PrjName
    {
      get { return ProjectIdSource == null ? string.Empty : ProjectIdSource.PrjName; }
    }

    then

    TList<ProjectCost> projectCosts = DataRepository.ProjectCostProvider.GetAll();
    DataRepository.ProjectCostProvider.DeepLoad(projectCosts, true, DeepLoadType.IncludeChildren, new Type[] {typeof(Project)} );

    I would then set projectCosts as the DataSource on the user control.

    If you want to customize the .netTiers user control to have an additional field then perhaps you can modify its constructor in the non-generated file to add your additional column.

    EDIT: alternatively can't you just create a sql view to return the columns you want and bind the VList to the user control's data source instead?

  • Hello.

     

    Well, quite simply, if you want an EntityGridView with columns from different sources, use a View.

    In SQL Server, create a new view and you can select what columns you want from whatever tables that you join together.

    NetTiers can generate DataSources for all your views, and this is what you should be using as the data source for EntityGridViews - it's much more flexible than using traditional entity data sources.

     

    Richard

Page 1 of 1 (5 items)