Duplication of data (columns) when using LeftJoin with Editor (.NET)

Duplication of data (columns) when using LeftJoin with Editor (.NET)

joshlevine102joshlevine102 Posts: 44Questions: 16Answers: 2

Hi guys. I'm using the .NET Editor WebApi to retrieve the data for DataTables, and I'm using the Editor plugin. I'm using LeftJoin to bring in data from tables with references. I'm noticing I get a lot of duplication of the data which is returned. It seems like, I get the data returned for each column in the main table which is included in my model. I also get one field returned for each Editor field I have (I assume I need an Editor Field in order to edit these columns with the editor), and I also get fields for the joined columns I'm using (which I expect). For example, one data item/row looks like the following in the returned JSON. Does anyone know if I'm doing something obviously wrong? If I'd like to just have each column like Organization_Name appearing only once in the response, is there a way to do this? Thanks.

        {
            "DT_RowId": "row_5621",
            "bis401_sites": {
                "Organization_Name": "Josh's Site NOT A REAL SITE",
                "Super_First_name": "Josh L",
                "Super_Title": "Supervisor",
                "Super_Email_Address": "hahaha",
                "Organization_Addr_1": "BLABLABLA",
                "Organization_Addr_2": "",
                "Organization_City": "Tempe",
                "Organization_State": "AZ",
                "Organization_ZIP": "85281",
                "Organization_Phone_NUmber": "6025551212",
                "Organization_Web_Address": "https://google.com",
                "ASURITE_ID": "",
                "Semester": "",
                "SessionCode": "",
                "categoryID": "9",
                "statusID": "3",
                "Site_Submit_Date": "2018-03-23"
            },
            "category": {
                "categoryName": "Science, Technology, Engineering, Mathematics"
            },
            "bis401_sites_status": {
                "status": "Hidden"
            },
            "Site_ID": 5621,
            "Site_Submit_Date": "2018-03-23T08:05:57.59",
            "ASURITE_ID": "",
            "Semester": "",
            "Super_First_name": "Josh L",
            "Super_Last_Name": "",
            "Super_Title": "Supervisor",
            "Super_Email_Address": "hahaha",
            "Organization_Name": "Josh's Site NOT A REAL SITE",
            "Organization_Addr_1": "BLABLABLA",
            "Organization_Addr_2": "",
            "Organization_City": "",
            "Organization_State": "AZ",
            "Organization_ZIP": "85281",
            "Organization_Area_Code": "",
            "Organization_Phone_NUmber": "6025551212",
            "Organization_Fax_Area_Code": "",
            "Organization_Fax_Number": null,
            "Organization_Web_Address": "https://google.com",
            "Completed": true,
            "MentorCheck": 0,
            "categoryID": 9,
            "approved": null,
            "placementAgreementDate": "1900-01-01T00:00:00",
            "notificationSent": null,
            "Hidden": false,
            "SessionCode": "",
            "statusID": 3
        },

This question has an accepted answers - jump to answer

Answers

  • joshlevine102joshlevine102 Posts: 44Questions: 16Answers: 2

    Ah, I think I'm seeing something in the JoinController, using two model classes, in the examples which may point me in the right direction.

  • allanallan Posts: 61,892Questions: 1Answers: 10,144 Site admin
    Answer ✓

    Yes, you can use inner classes to creating the nesting, or (as of Editor 1.7) pass the table name to the Model() method along with the class (as the generic parameter):

                        .Model<JoinModelUsers>("users")
                        .Model<JoinModelSites>("sites")
    

    I'll update the example to use that method as the inner class, as I understand it, isn't particularly common in the .NET world.

    Allan

  • joshlevine102joshlevine102 Posts: 44Questions: 16Answers: 2

    Allan. Yes, I'm using three Model(s) like that now, and that works well. There seems to be no duplication now of the data returned.

This discussion has been closed.