locked
Linq queries in VB RRS feed

  • Question

  • Recently started trying out lightswitch but cant get my head around LINQ queries, so i tried to use a program called Linqer to generate the linq queries from sql.

    I upload data from excel, but then need to split the data into various tables, i can do this on the SQL server as a server agent job, but if it fails the error is not visable to the user, so i want to be able to trigger the event from a button.

    but when i covert this:

    INSERT INTO ClearanceContent
                          (Material, VKBNo, Description, QTY, UOM, Cartons, pallets, ProductGRP, ContainerNo, OrderNo, Ref, Storage_Location, Storage_Location_Des)
    SELECT     DataImport.MaterialNo, DataImport.VKBNumber, DataImport.Description, DataImport.QTY, DataImport.Unit, DataImport.Cartons, DataImport.Pallets, 
                          DataImport.ProductGRP, DataImport.ContainerNo, DataImport.OrderNo, IMDReference.IMDNumber, DataImport.Stlocation, DataImport.StorLocDesc
    FROM         DataImport INNER JOIN
                          IMDReference ON DataImport.ContainerNo = IMDReference.ContainerNo

    the result is :

            Private Sub Split_Execute()
                Dim queryClearanceContent =
                   From DataImport In DataImports
                   Join IMDReference In IMDReferences On New With {DataImport.ContainerNo} Equals New With {IMDReference.ContainerNo}
                   Select
                     DataImport.MaterialNo,
                     DataImport.VKBNumber,
                     DataImport.Description,
                     DataImport.QTY,
                     DataImport.Unit,
                     DataImport.Cartons,
                     DataImport.Pallets,
                     DataImport.ProductGRP,
                     DataImport.ContainerNo,
                     DataImport.OrderNo,
                     IMDReference.IMDNumber,
                     DataImport.Stlocation,
                     DataImport.StorLocDesc
    
                For Each q As Object In queryClearanceContent
                    Dim iClearanceContent As New ClearanceContent With { _
                        .Material = q.MaterialNo, _
                        .VKBNo = q.VKBNumber, _
                        .Description = q.Description, _
                        .QTY = q.QTY, _
                        .UOM = q.Unit, _
                        .Cartons = q.Cartons, _
                        .pallets = q.Pallets, _
                        .ProductGRP = q.ProductGRP, _
                        .ContainerNo = q.ContainerNo, _
                        .OrderNo = q.OrderNo, _
                        .Ref = q.IMDNumber, _
                        .Storage_Location = q.Stlocation, _
                        .Storage_Location_Des = q.StorLocDesc _
                    }
    
                Next
                Save()
            End Sub

    however i get an error stating 'IMDReferences' is not declared.it may be inaccessible due to its protection level.

    IMDreferences is a table just like DataImports, Whats wrong ?

    A simple answer would be great, and any pointers, only just started to understand the basics.

    Many Thanks

    Tuesday, July 30, 2013 12:48 PM