This is a migrated thread and some comments may be shown as answers.

Data from Join tables not being displayed properly

1 Answer 48 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Clement
Top achievements
Rank 1
Clement asked on 12 Sep 2012, 03:04 PM
I'm displaying a List of Schemes on a grid and two of the columns are from the following join tables.

  1. SchemeTown -- stores towns associated with the scheme (scheme_id, town_id)
  2. SchemeDivision - stores divisions associated with the scheme (scheme_id, division_id)

on the grid, among other information, I'm successfully displaying name of the town and division for each scheme.

Problem comes when I export this data to an excel sheet or of I want to display this data in a report, the town and division name are not exported, I've attached an excel sheet to show how they are being outputted.

The export to excel and report display get their data from the same data source as the grid mentioned above. The following code block shows how this data is retrieved from the database.

public List<SchemeSystem> GetAllSchemeSystems()
        {
            return (from schemeSystem in DataHandler.Extent<SchemeSystem>() where schemeSystem.Planned == false & schemeSystem.Id != Guid.Empty select schemeSystem).ToList<SchemeSystem>();
        }


and the following is the SchemeSystem entity
public partial class SchemeSystem
   {
 
       //The 'no-args' constructor required by OpenAccess.
       public SchemeSystem()
       {
       }
 
       [Telerik.OpenAccess.FieldAlias("id")]
       public Guid Id
       {
           get { return id; }
           private set { id = value; }
       }
 
       [Telerik.OpenAccess.FieldAlias("name")]
       public string Name
       {
           get { return name; }
           set { this.name = value; }
       }
 
              
       [Telerik.OpenAccess.FieldAlias("wsp")]
       public Wsp Wsp
       {
           get { return wsp; }
           set { this.wsp = value; }
       }
 
       [Telerik.OpenAccess.FieldAlias("planned")]
       public bool Planned
       {
           get { return planned; }
           set { this.planned = value; }
       }
 
       [Telerik.OpenAccess.FieldAlias("schemeSystemData")]
       public IList<SchemeSystemData> SchemeSystemDatas
       {
           get { return schemeSystemData; }
       }
 
       [Telerik.OpenAccess.FieldAlias("schemeTowns")]
       public IList<Town> schemeTown
       {
           get { return schemeTowns; }
       }
       [Telerik.OpenAccess.FieldAlias("schemeDivisions")]
       public IList<Division> schemeDivision
       {
           get { return schemeDivisions; }
       }
      
              
   }

What do I need to do to display the Division and Town names in my report and Excel?

1 Answer, 1 is accepted

Sort by
0
Viktor Zhivkov
Telerik team
answered on 17 Sep 2012, 12:15 PM
Hello,

My suggestion is to define a Fetch Strategy,Plan or Group that load schemeTown and schemeDivision collections explicitly before exporting data to Excel. 
This can find more information how to use Fetch Plans and our Extent based API in this set of articles or check how to use the new context based API in this article.

If you need further assistance please post the code that does the actual export to the Excel file.

All the best,
Viktor Zhivkov
the Telerik team
Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
Tags
Development (API, general questions)
Asked by
Clement
Top achievements
Rank 1
Answers by
Viktor Zhivkov
Telerik team
Share this question
or