You can find the code for this example in the ERPConnect installation directory in the LINQQuery directory.
Apart from the table integration described in the previous two sections, LINQ to SAP also supports SAP queries as LINQ-capable data sources (important: do not mix these up with BW queries!). The following example demonstrates how a demo query called ZVV01 is addressed in the ZTHEO user group. The screenshot below shows the query’s selection screen, as well as the list output. The contents output here by the query (join between VBAK and VBAP) are sales data.
To activate a query on the .NET end, drag the query symbol from the toolbox to the data context. You have access to a search mask after logging on.
In the dialog you can specify whether the values for each select option should be accessible in the code or not (Pass is checked off here) and, if so, what the variable name should be (the default name given by SAP might be rather cryptic). An additional variant can also be applied here. In the upper right-hand area, the name of the later DataContext method is defined (Method), as well as what the class that represents a single row should be called (Object) and what the class should be called which represents the entire query output (Collection).
In the fields tab, unneeded fields can be unchecked or renamed.
As the following code snippet shows, the DataContext class now offers a function to execute the query. As a parameter value you’ll be able to recognize both of the select options in IntelliSense.
Both parameter values correspond with the range objects introduced in section Example for calling a query. Here is the code now for the query. Text boxes serve as variables here (see screenshot below).
Click to open C# example.