Selft Join - C#

Selft Join - C#

samevedzisamevedzi Posts: 14Questions: 3Answers: 0
edited April 26 in Editor

Hi,

I am trying to use the self join code example. I have the User table that is joined to the Requisition table using the User_ID field which works fine.

I am trying to join another User table to the Requisition table using the CurrentUser_ID field as highlighted below but doesn't work.

What is wrong with the way I am applying the self join?

var response = new Editor(db, "Requisition", "ID")
    .Model<Requisition>("Requisition")
    .Model<User>("User")
    .LeftJoin("dbo.User", "User.ID", "=", "Requisition.User_ID")                      
    .Field(new Field("Requisition.User_ID")
        .Options("dbo.User", "ID", "Username")
        .Set(Field.SetType.Create).SetValue(User_ID)
        .Validator(Validation.DbValues(new ValidationOpts { Empty = false }))
    )
    .Model<User>("CurrentUser")
    .LeftJoin("dbo.User as CurrentUser", "CurrentUser.ID", "=", "Requisition.CurrentUser_ID")
    .Field(new Field("Requisition.CurrentUser_ID")
    .Options("CurrentUser", "ID", "Username")
    )
    .Process(formData)
    .Data();

Thanks in advance for your help.

---Stephen

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • allanallan Posts: 54,897Questions: 1Answers: 8,605 Site admin

    Hi Stephen,

    Are you getting an error when you run that, or something else? If an error, what is it?

    Also, you could you try adding .Debug(true) immediately before the .Process(...) call and show me the JSON response from the server please?

    Thanks,
    Allan

  • samevedzisamevedzi Posts: 14Questions: 3Answers: 0

    Hi,

    There is no error from the server side. However, the client returns the following alert message: DataTables warning: table id=Table_Requisition - Incorrect syntax near the keyword 'User'.

    The JSON response is as follows:

    {
        "draw": null,
        "data": [],
        "recordsTotal": null,
        "recordsFiltered": null,
        "error": "Incorrect syntax near the keyword 'User'.",
        "fieldErrors": [],
        "id": null,
        "meta": {},
        "options": {},
        "files": {},
        "upload": {
            "id": null
        },
        "debug": [
            {
                "Query": "SELECT  [Requisition].[ID] as 'Requisition.ID', [Requisition].[User_ID] as 'Requisition.User_ID', [Requisition].[CurrentUser_ID] as 'Requisition.CurrentUser_ID', [Requisition].[Item_ID] as 'Requisition.Item_ID', [Requisition].[Item_Group_ID] as 'Requisition.Item_Group_ID', [Requisition].[Subsidiary_ID] as 'Requisition.Subsidiary_ID', [Requisition].[Location_ID] as 'Requisition.Location_ID', [Requisition].[Department_ID] as 'Requisition.Department_ID', [Requisition].[Unit_ID] as 'Requisition.Unit_ID', [Requisition].[Vendor_ID] as 'Requisition.Vendor_ID', [Requisition].[DateRequested] as 'Requisition.DateRequested', [Requisition].[Status] as 'Requisition.Status', [Requisition].[CurrentUser_ID] as 'Requisition.CurrentUser_ID', [Requisition].[Qty] as 'Requisition.Qty', [Requisition].[Cost] as 'Requisition.Cost', [Requisition].[DateExpected] as 'Requisition.DateExpected', [Requisition].[Qty_Supplied] as 'Requisition.Qty_Supplied', [Requisition].[Qty_Received] as 'Requisition.Qty_Received', [Requisition].[Qty_Rejected] as 'Requisition.Qty_Rejected', [Requisition].[Rating] as 'Requisition.Rating', [Requisition].[Remarks] as 'Requisition.Remarks', [Requisition].[Active] as 'Requisition.Active', [Requisition].[Vendor_TaxRate] as 'Requisition.Vendor_TaxRate', [Requisition].[DetailedDescription] as 'Requisition.DetailedDescription', [Requisition].[StatusChangeDate] as 'Requisition.StatusChangeDate', [User].[ID] as 'User.ID', [User].[Email] as 'User.Email', [User].[Username] as 'User.Username', [User].[FirstName] as 'User.FirstName', [User].[LastName] as 'User.LastName', [User].[UserType] as 'User.UserType', [User].[Subsidiary_ID] as 'User.Subsidiary_ID', [User].[Location_ID] as 'User.Location_ID', [User].[Department_ID] as 'User.Department_ID', [User].[Unit_ID] as 'User.Unit_ID', [User].[Active] as 'User.Active', [User].[OnLeave] as 'User.OnLeave', [User].[Reset_Password] as 'User.Reset_Password', [CurrentUser].[ID] as 'CurrentUser.ID', [CurrentUser].[Email] as 'CurrentUser.Email', [CurrentUser].[Username] as 'CurrentUser.Username', [CurrentUser].[FirstName] as 'CurrentUser.FirstName', [CurrentUser].[LastName] as 'CurrentUser.LastName', [CurrentUser].[UserType] as 'CurrentUser.UserType', [CurrentUser].[Subsidiary_ID] as 'CurrentUser.Subsidiary_ID', [CurrentUser].[Location_ID] as 'CurrentUser.Location_ID', [CurrentUser].[Department_ID] as 'CurrentUser.Department_ID', [CurrentUser].[Unit_ID] as 'CurrentUser.Unit_ID', [CurrentUser].[Active] as 'CurrentUser.Active', [CurrentUser].[OnLeave] as 'CurrentUser.OnLeave', [CurrentUser].[Reset_Password] as 'CurrentUser.Reset_Password', [Item].[ID] as 'Item.ID', [Item].[Item_Group_ID] as 'Item.Item_Group_ID', [Item].[Item_Name] as 'Item.Item_Name', [Item].[Code] as 'Item.Code', [Item].[Description] as 'Item.Description', [Item].[Taxable] as 'Item.Taxable', [Item].[Service_Item] as 'Item.Service_Item', [Item].[Active] as 'Item.Active', [Item].[Sourcing_Approved_Create] as 'Item.Sourcing_Approved_Create', [Item_Group].[ID] as 'Item_Group.ID', [Item_Group].[Code] as 'Item_Group.Code', [Item_Group].[Description] as 'Item_Group.Description', [Item_Group].[Active] as 'Item_Group.Active', [Subsidiary].[ID] as 'Subsidiary.ID', [Subsidiary].[Code] as 'Subsidiary.Code', [Subsidiary].[Description] as 'Subsidiary.Description', [Subsidiary].[Active] as 'Subsidiary.Active', [Location].[ID] as 'Location.ID', [Location].[Code] as 'Location.Code', [Location].[Description] as 'Location.Description', [Location].[Active] as 'Location.Active', [Department].[ID] as 'Department.ID', [Department].[Code] as 'Department.Code', [Department].[Description] as 'Department.Description', [Department].[Active] as 'Department.Active', [Unit].[ID] as 'Unit.ID', [Unit].[Code] as 'Unit.Code', [Unit].[Description] as 'Unit.Description', [Unit].[Active] as 'Unit.Active', [Vendor].[ID] as 'Vendor.ID', [Vendor].[Username] as 'Vendor.Username', [Vendor].[Name] as 'Vendor.Name', [Vendor].[Password] as 'Vendor.Password', [Vendor].[Active] as 'Vendor.Active', [Vendor].[Reset_Password] as 'Vendor.Reset_Password', [Vendor].[Title] as 'Vendor.Title', [Vendor].[Contact_Person] as 'Vendor.Contact_Person', [Vendor].[Physical_Address] as 'Vendor.Physical_Address', [Vendor].[Postal_Address] as 'Vendor.Postal_Address', [Vendor].[Telephone] as 'Vendor.Telephone', [Vendor].[Fax] as 'Vendor.Fax', [Vendor].[Tax_Number] as 'Vendor.Tax_Number', [Vendor].[Registration] as 'Vendor.Registration', [Vendor].[Email] as 'Vendor.Email', [Vendor].[Registration_Date] as 'Vendor.Registration_Date' FROM  [Requisition] LEFT JOIN [dbo].[User] ON [User].[ID] = [Requisition].[User_ID]  LEFT JOIN dbo.User AS CurrentUser ON [CurrentUser].[ID] = [Requisition].[CurrentUser_ID]  LEFT JOIN [dbo].[Item] ON [Item].[ID] = [Requisition].[Item_ID]  LEFT JOIN [dbo].[Item_Group] ON [Item_Group].[ID] = [Requisition].[Item_Group_ID]  LEFT JOIN [dbo].[Subsidiary] ON [Subsidiary].[ID] = [Requisition].[Subsidiary_ID]  LEFT JOIN [dbo].[Location] ON [Location].[ID] = [Requisition].[Location_ID]  LEFT JOIN [dbo].[Department] ON [Department].[ID] = [Requisition].[Department_ID]  LEFT JOIN [dbo].[Unit] ON [Unit].[ID] = [Requisition].[Unit_ID]  LEFT JOIN [dbo].[Vendor] ON [Vendor].[ID] = [Requisition].[Vendor_ID] WHERE [Requisition].[User_ID] >= @where_0 AND [Requisition].[Status] != @where_1 ",
                "Bindings": [
                    {
                        "Name": "@where_0",
                        "Value": 0,
                        "Type": null
                    },
                    {
                        "Name": "@where_1",
                        "Value": "Closed",
                        "Type": null
                    }
                ]
            }
        ],
        "cancelled": []
    }
    

    Thanks,
    --Stephen

  • allanallan Posts: 54,897Questions: 1Answers: 8,605 Site admin

    Hi Stephen,

    Could you replace:

    .LeftJoin("dbo.User as CurrentUser",
    

    with:

    .LeftJoin("[dbo].[User] as CurrentUser",
    

    It looks like the escaping might be wrong (actually, non-existent) for cases when an alias is given.

    Thanks,
    Allan

  • samevedzisamevedzi Posts: 14Questions: 3Answers: 0

    Hi Allan,

    Thanks for the response once again.

    I did the replacement but I get DataTables warning: table id=Table_Requisition - Duplicate field detected - a field with the name Requisition.CurrentUser_ID already exists from the client side.

    The JSON response is as follows:

    draw    null
    data    []
    recordsTotal    null
    recordsFiltered null
    error   "Duplicate field detected - a field with the name `Requisition.CurrentUser_ID` already exists."
    fieldErrors []
    id  null
    meta    Object { }
    options Object { }
    files   Object { }
    upload  Object { id: null }
    id  null
    debug   [ {…} ]
    0   Object { Query: "SELECT [Requisition].[ID] as 'Requisition.ID', [Requisition].[User_ID] as 'Requisition.User_ID', [Requisition].[CurrentUser_ID] as 'Requisition.CurrentUser_ID', [Requisition].[CurrentUser_ID] as 'Requisition.CurrentUser_ID', [Requisition].[Item_ID] as 'Requisition.Item_ID', [Requisition].[Item_Group_ID] as 'Requisition.Item_Group_ID', [Requisition].[Subsidiary_ID] as 'Requisition.Subsidiary_ID', [Requisition].[Location_ID] as 'Requisition.Location_ID', [Requisition].[Department_ID] as 'Requisition.Departm…[Item_Group].[ID] = [Requisition].[Item_Group_ID] LEFT JOIN [dbo].[Subsidiary] ON [Subsidiary].[ID] = [Requisition].[Subsidiary_ID] LEFT JOIN [dbo].[Location] ON [Location].[ID] = [Requisition].[Location_ID] LEFT JOIN [dbo].[Department] ON [Department].[ID] = [Requisition].[Department_ID] LEFT JOIN [dbo].[Unit] ON [Unit].[ID] = [Requisition].[Unit_ID] LEFT JOIN [dbo].[Vendor] ON [Vendor].[ID] = [Requisition].[Vendor_ID] WHERE [Requisition].[User_ID] >= @where_0 AND [Requisition].[Status] != @where_1 ", Bindings: […] }
    Query   "SELECT [Requisition].[ID] as 'Requisition.ID', [Requisition].[User_ID] as 'Requisition.User_ID', [Requisition].[CurrentUser_ID] as 'Requisition.CurrentUser_ID', [Requisition].[CurrentUser_ID] as 'Requisition.CurrentUser_ID', [Requisition].[Item_ID] as 'Requisition.Item_ID', [Requisition].[Item_Group_ID] as 'Requisition.Item_Group_ID', [Requisition].[Subsidiary_ID] as 'Requisition.Subsidiary_ID', [Requisition].[Location_ID] as 'Requisition.Location_ID', [Requisition].[Department_ID] as 'Requisition.Departm…[Item_Group].[ID] = [Requisition].[Item_Group_ID] LEFT JOIN [dbo].[Subsidiary] ON [Subsidiary].[ID] = [Requisition].[Subsidiary_ID] LEFT JOIN [dbo].[Location] ON [Location].[ID] = [Requisition].[Location_ID] LEFT JOIN [dbo].[Department] ON [Department].[ID] = [Requisition].[Department_ID] LEFT JOIN [dbo].[Unit] ON [Unit].[ID] = [Requisition].[Unit_ID] LEFT JOIN [dbo].[Vendor] ON [Vendor].[ID] = [Requisition].[Vendor_ID] WHERE [Requisition].[User_ID] >= @where_0 AND [Requisition].[Status] != @where_1 "
    Bindings    [ {…}, {…} ]
    0   Object { Name: "@where_0", Value: 0, Type: null }
    Name    "@where_0"
    Value   0
    Type    null
    1   Object { Name: "@where_1", Value: "Closed", Type: null }
    Name    "@where_1"
    Value   "Closed"
    Type    null
    cancelled   []
    

    Thanks,
    ---Stephen

  • allanallan Posts: 54,897Questions: 1Answers: 8,605 Site admin

    Hi Stephen,

    That means you have two fields with the name Requisition.CurrentUser_ID on the client-side I think. Can you show me the Javascript for your Editor and also the data being submitted to the server-side please?

    Thanks,
    Allan

  • samevedzisamevedzi Posts: 14Questions: 3Answers: 0

    Hi Allan,

    Once again, thanks for the response.

    The details as requested are below:

    Editor:

            Editor_Requisition = new $.fn.dataTable.Editor({
                ajax: "/Requisitions/Current",
                table: "#Table_Requisition",
                fields: [
                    { label: "Item:", name: "Requisition.Item_ID", type: "select", placeholder: "Select an Item" },
                    { label: "Cost:", name: "Requisition.Cost" },
                    //Other Defaults - Start
                    { label: "Item_Group_ID:", name: "Requisition.Item_Group_ID", type:'hidden' },
                    { label: "Vendor_ID:", name: "Requisition.Vendor_ID", type: 'hidden' },
                    { label: "Vendor_Tax_Rate:", name: "Requisition.Vendor_TaxRate", type: 'hidden' },
                    //Other Defaults - End
                    { label: "Quantity:", name: "Requisition.Qty" },
                    { label: "Date Expected:", name: "Requisition.DateExpected",
                        type:      'datetime',
                        def:       function () { return new Date(); },
                        format:    'YYYY-MM-DD',
                        fieldInfo: 'Standard style y-m-d date input',
                        opts: {
                            minutesIncrement: 5
                        }
                    },
                    { label: "Detailed Description:", name: "Requisition.DetailedDescription" },
                ]
            }); 
            //Force retrieval of Default Values
            Editor_Requisition.dependent(
                'Requisition.Item_ID',
                function (val) {
                    if (val > 0) {
                        $.ajax({
                            url: '/Requisitions/Get_DefaultValues',
                            dataType: 'json',
                            data: {
                                Item_ID: val
                            },
                            success: function (json) {
                                //Set and disable Cost field
                                Editor_Requisition.field('Requisition.Cost').disable().val(json.current_cost);
                                Editor_Requisition.field('Requisition.Item_Group_ID').disable().val(json.item_group_id);
                                Editor_Requisition.field('Requisition.Vendor_ID').disable().val(json.vendor_id);
                                Editor_Requisition.field('Requisition.Vendor_TaxRate').disable().val(json.vendor_tax_rate);
                            }
                        });
                    }
                }
            );
    

    Datatable:

            Datatable_Requisition = $('#Table_Requisition').DataTable({
                dom: "Bfrtip",
                ajax: "/Requisitions/Current",
                order: [[1, 'asc']],
                columns: [
                    {
                        data: null,
                        defaultContent: '',
                        className: 'select-checkbox',
                        orderable: false
                    },
                    { "data": "Requisition.ID" },
                    { "data": "Requisition.DateRequested" },
                    { "data": "User.Username" },
                    { "data": "Item.Description" },
                    { "data": "Requisition.Qty" },
                    { "data": "Requisition.Cost" },
                    { "data": "Requisition.DateExpected" },
                    { "data": "Item_Group.Description" },
                    { "data": "Subsidiary.Description" },
                    { "data": "Location.Description" },
                    { "data": "Department.Description" },
                    { "data": "Unit.Description" },
                    { "data": "Requisition.Status" },
                    { "data": "Requisition.CurrentUser_ID" },
                    { "data": "Requisition.Qty_Supplied" },
                    { "data": "Requisition.Qty_Received" },
                    { "data": "Requisition.Qty_Rejected" },
                    { "data": "Requisition.Rating" },
                    { "data": "Requisition.Remarks" },
                    { "data": "Requisition.Active", "render": function (val, type, row) {
                            return val == 0 ? "No" : "Yes";
                    }
                    },
                    { "data": "Vendor.Name" },
                    { "data": "Requisition.Vendor_TaxRate" },
                    { "data": "Requisition.DetailedDescription" },
                    { "data": "Requisition.StatusChangeDate" }
                ],
                scrollY: ($(window).height() - 290),
                scrollX: true,
                scrollCollapse: true,
                select: true,
                select: true,
                buttons: [
                    { extend: "create",
                        text: 'Add',
                        editor: Editor_Requisition
                    },
                    { extend: "edit", editor: Editor_Requisition },
                    { extend: "remove", editor: Editor_Requisition },
                    {
                        extend: 'collection',
                        text: 'Export',
                        buttons: [
                            'excel',
                            'csv',
                            'pdf',
                            'print'
                        ]
                    }
                ]
            });
    
    

    There is no data sent to the server.

    Thanks,
    ---Stephen

  • allanallan Posts: 54,897Questions: 1Answers: 8,605 Site admin

    Hi Stephen,

    I have to apologise - I got totally confused yesterday and thought it was an issue when submitting the data. In fact it is when it is reading the data the error comes up I understand now... Sorry about that!

    This is part of the query being executed:

    SELECT
        [Requisition].[ID] as 'Requisition.ID',
        [Requisition].[User_ID] as 'Requisition.User_ID',
        [Requisition].[CurrentUser_ID] as 'Requisition.CurrentUser_ID',
        [Requisition].[CurrentUser_ID] as 'Requisition.CurrentUser_ID',
        [Requisition].[Item_ID] as 'Requisition.Item_ID',
        [Requisition].[Item_Group_ID] as 'Requisition.Item_Group_ID',
        [Requisition].[Subsidiary_ID] as 'Requisition.Subsidiary_ID',
        [Requisition].[Location_ID] as 'Requisition.Location_ID',
        [Requisition].[Department_ID] as 'Requisition.Departm
        ?
        [Item_Group].[ID] = [Requisition].[Item_Group_ID]
    LEFT JOIN [dbo].[Subsidiary] ON [Subsidiary].[ID] = [Requisition].[Subsidiary_ID]
    LEFT JOIN [dbo].[Location] ON [Location].[ID] = [Requisition].[Location_ID]
    LEFT JOIN [dbo].[Department] ON [Department].[ID] = [Requisition].[Department_ID]
    LEFT JOIN [dbo].[Unit] ON [Unit].[ID] = [Requisition].[Unit_ID]
    LEFT JOIN [dbo].[Vendor] ON [Vendor].[ID] = [Requisition].[Vendor_ID]
    WHERE
        [Requisition].[User_ID] >= @where_0 AND
        [Requisition].[Status] != @where_1 "
    

    I can see that there is:

        [Requisition].[CurrentUser_ID] as 'Requisition.CurrentUser_ID',
        [Requisition].[CurrentUser_ID] as 'Requisition.CurrentUser_ID',
    

    Which is what is causing this error. As to why it is happening... Could you show me your full C# code for this instance please?

    Thanks,
    Allan

  • samevedzisamevedzi Posts: 14Questions: 3Answers: 0

    Hi Allan,

    Apologies for the delay in responding. I had some emergencies to take care of.

    Kindly find below as requested:

                        int User_ID = (int)Session["ID"];
                        string UserType = (string)Session["UserType"];
    
                        int User_ID_For_Where_Operator = User_ID;
                        string User_ID_Where_Operator = "=";
    
                        if (UserType.Equals("Sourcing"))
                        {
                            User_ID_For_Where_Operator = 0;
                            User_ID_Where_Operator = ">=";
                        }
    
                        var response = new Editor(db, "Requisition", "ID")
                            .Model<Requisition>("Requisition")
                            .Model<User>("User")
                            .LeftJoin("dbo.User", "User.ID", "=", "Requisition.User_ID")                        
                            .Field(new Field("Requisition.User_ID")
                                .Options("dbo.User", "ID", "Username")
                                .Set(Field.SetType.Create).SetValue(User_ID)
                                .Validator(Validation.DbValues(new ValidationOpts { Empty = false }))
                            )
    
                            .Model<User>("CurrentUser")
                            .LeftJoin("[dbo].[User] as CurrentUser", "CurrentUser.ID", "=", "Requisition.CurrentUser_ID")
                            .Field(new Field("Requisition.CurrentUser_ID")
                                .Options("CurrentUser", "ID", "Username")
                                .Set(Field.SetType.Create).SetValue(User_ID)
                            )
                            .Model<Item>("Item")
                            .LeftJoin("dbo.Item", "Item.ID", "=", "Requisition.Item_ID")
                            .Field(new Field("Requisition.Item_ID")
                                .Options("dbo.Item", "ID", "Description")
                                .Validator(Validation.DbValues(new ValidationOpts { Empty = false }))
                            )
                            .Model<Item_Group>("Item_Group")
                            .LeftJoin("dbo.Item_Group", "Item_Group.ID", "=", "Requisition.Item_Group_ID")
                            .Field(new Field("Requisition.Item_Group_ID")
                                .Options("dbo.Item_Group", "ID", "Description")
                                .Validator(Validation.DbValues(new ValidationOpts { Empty = false }))
                            )
                            .Model<Subsidiary>("Subsidiary")
                            .LeftJoin("dbo.Subsidiary", "Subsidiary.ID", "=", "Requisition.Subsidiary_ID")
                            .Field(new Field("Requisition.Subsidiary_ID")
                                .Options("dbo.Subsidiary", "ID", "Description")
                                .Validator(Validation.DbValues(new ValidationOpts { Empty = false }))
                                .Set(Field.SetType.Create).SetValue((int)Session["Subsidiary_ID"])
                            )
                            .Model<Location>("Location")
                            .LeftJoin("dbo.Location", "Location.ID", "=", "Requisition.Location_ID")
                            .Field(new Field("Requisition.Location_ID")
                                .Options("dbo.Location", "ID", "Description")
                                .Validator(Validation.DbValues(new ValidationOpts { Empty = false }))
                                .Set(Field.SetType.Create).SetValue((int)Session["Location_ID"])
                            )
                            .Model<Department>("Department")
                            .LeftJoin("dbo.Department", "Department.ID", "=", "Requisition.Department_ID")
                            .Field(new Field("Requisition.Department_ID")
                                .Options("dbo.Department", "ID", "Description")
                                .Validator(Validation.DbValues(new ValidationOpts { Empty = false }))
                                .Set(Field.SetType.Create).SetValue((int)Session["Department_ID"])
                            )
                            .Model<Unit>("Unit")
                            .LeftJoin("dbo.Unit", "Unit.ID", "=", "Requisition.Unit_ID")
                            .Field(new Field("Requisition.Unit_ID")
                                .Options("dbo.Unit", "ID", "Description")
                                .Validator(Validation.DbValues(new ValidationOpts { Empty = false }))
                                .Set(Field.SetType.Create).SetValue((int)Session["Unit_ID"])
                            )
                            .Model<Vendor>("Vendor")
                            .LeftJoin("dbo.Vendor", "Vendor.ID", "=", "Requisition.Vendor_ID")
                            .Field(new Field("Requisition.Vendor_ID")
                                .Options("dbo.Vendor", "ID", "Name")
                                .Validator(Validation.DbValues(new ValidationOpts { Empty = false }))
                            )
                            .Where("Requisition.User_ID", User_ID_For_Where_Operator, User_ID_Where_Operator)
                            .Where("Requisition.Status", "Closed", "!=")
                            //Default Values
                            .Field(new Field("Requisition.DateRequested").Set(Field.SetType.Create).SetValue(DateTime.Now))
                            .Field(new Field("Requisition.Status").Set(Field.SetType.Create).SetValue("Added"))
                            .Debug(true)
                            .Process(formData)
                            .Data();
    

    Thanks,
    ---Stephen

  • allanallan Posts: 54,897Questions: 1Answers: 8,605 Site admin

    Hi Stephen,

    Could you show me the models you are using here as well please. I suspect we will need to try to recreate this, to understand what is going wrong.

    Allan

  • samevedzisamevedzi Posts: 14Questions: 3Answers: 0

    Hi Allan,

    Thanks for the response.

    Kindly find below the models:

    Requisition:

    public class Requisition
        {
            [Key]
            public int ID { get; set; }
            public string DateRequested { get; set; }
            public int User_ID { get; set; }
            public int Item_ID { get; set; }
            public int Qty { get; set; }
            public decimal Cost { get; set; }
            public string DateExpected { get; set; }
            public int Item_Group_ID { get; set; }
            public int Subsidiary_ID { get; set; }
            public int Location_ID { get; set; }
            public int Department_ID { get; set; }
            public int Unit_ID { get; set; }
            public string Status { get; set; }
            public int CurrentUser_ID { get; set; }
            public int Qty_Supplied { get; set; }
            public int Qty_Received { get; set; }
            public int Qty_Rejected { get; set; }
            public int Rating { get; set; }
            public string Remarks { get; set; }
            public bool Active { get; set; }
            public int Vendor_ID { get; set; }
            public int Vendor_TaxRate { get; set; }
            public string DetailedDescription { get; set; }
            public string StatusChangeDate { get; set; }
        }
    

    User:

    public class User
        {
            public int ID { get; set; }
            public string Email { get; set; }
            public string Username { get; set; }
            public string FirstName { get; set; }
            public string LastName { get; set; }
            public string UserType { get; set; }
            public int Subsidiary_ID { get; set; }
            public int Location_ID { get; set; }
            public int Department_ID { get; set; }
            public int Unit_ID { get; set; }
            public string Active { get; set; }
            public string OnLeave { get; set; }
            public string Reset_Password { get; set; }
        }
    

    Item:

        public class Item
        {
            public int ID { get; set; }        
            public int? Item_Group_ID { get; set; }
            public string Item_Name { get; set; }
            public string Code { get; set; }       
            public string Description { get; set; }
            public bool Taxable { get; set; }        
            public bool Service_Item { get; set; }               
            public bool Active { get; set; }
            public bool Sourcing_Approved_Create { get; set; }
        }
    

    Item Group:

        public class Item_Group
        {
            public int ID { get; set; }
            public string Code { get; set; }
            public string Description { get; set; }
            public string Active { get; set; }
           
        }
    

    Subsidiary:

        public class Subsidiary
        {
            [Key]
            public int ID { get; set; }
            public string Code { get; set; }
            public string Description { get; set; }
            public string Active { get; set; }
        }
    

    Location:

        public class Location
        {        
            public int ID { get; set; }
            public string Code { get; set; }
            public string Description { get; set; }
            public string Active { get; set; }
        }
    

    Department:

        public class Department
        {        
            public int ID { get; set; }
            public string Code { get; set; }
            public string Description { get; set; }
            public string Active { get; set; }
        }
    

    Unit:

        public class Unit
        {
            public int ID { get; set; }
            public string Code { get; set; }
            public string Description { get; set; }
            public string Active { get; set; }
        }
    

    Vendor:

    public class Vendor
        {       
            public int ID { get; set; }
            public string Username { get; set; }
            public string Name { get; set; }
            public string Password { get; set; }
            public bool Active { get; set; }
            public bool Reset_Password { get; set; }
            public string Title { get; set; }
            public string Contact_Person { get; set; }
            public string Physical_Address { get; set; }
            public string Postal_Address { get; set; }
            public string Telephone { get; set; }
            public string Fax { get; set; }
            public string Tax_Number { get; set; }
            public string Registration { get; set; }
            public string Email { get; set; }
            public string Registration_Date { get; set; }
        }
    

    Thanks,
    ---Stephen

Sign In or Register to comment.