Calling a Method in the Linq Query Select Statement
-
Friday, February 15, 2013 10:47 PM
I have a query where I have items selected in Multiple tables and I am calling a method and returning arraylist before binding it to the radgrid. But when I click on Details view Next to Items Selected I am seeing : System.Collections.ArrayList.
How can I display a list of items in the grid??
Dim query = (From p In dc1.Products Join Acc In dc1.AccessSelections On p.ProductId Equals Acc.ProductId Where Acc.RequestStatus = "Submitted" Join sd In dc1.ShareDetails On p.ProducId Equals sd.ProductIdId _ Join rd In dc1.RequestorDetails On p.ProductId Equals rd.ProductId Order By r.RequestedOn Descending Join ud In dc1.UsageDetails On P.ProductId Equals ud.ProductId Where Not ud.Classification = "" _ Select ProductId = p.ProductId.ToString(), _ UsagePlanName = ud.UsagePlanName.ToString(), _ UsagePlanId = ud.UsagePlanId .ToString(), _ ItemsSelected = getItemsSelected(r.productId), _ ProductType = Acc.RequestType.ToString(), _ Status = Acc.RequestStatus.ToString())I have the Items selected for different Products in Different Tables, So I am Calling getitemsSelected(ProductId)
Public Shared Function getItemsSelected(ByVal ProductId As String) As ArrayList Try Dim Al1 As New ArrayList Using dc1 As New TestDataClassesDataContext() Dim query = (From queryitem In dc1.AccessSelections Where queryitem.ProductId = ProductId Select queryitem) If Not query Is Nothing Then If query.Count > 0 Then Dim queryResults = (From queryItem In query Select queryItem).ToList() For Each item In queryResults If item.SelectedAreas = 1 Then Al1 = LoadInventoryItems(ProductId) ElseIf item.SelectedAreas = 5 Then al1=LoadRefurbishedItems(ProductId) End if ..... ........ Next End If End If End Using Return Al1 Catch ex As Exception LogException(ex) End Try End Function Public Shared Function LoadInventoryItems(ByVal ProductId As String) As ArrayList Dim Al As New ArrayList Using dc1 As New TestDataClassesDataContext() Dim query = (From queryItem In dc1.InventoryDetails Where queryItem.ProductId = ProductId Select queryItem) If Not query Is Nothing Then If query.Count > 0 Then Dim queryResults = (From queryItem In query Select queryItem).ToList() For Each item In queryResults Al.Add("Inventory A" & item.inventoryA) Al.Add("Inventory B" & item.inventoryB) Al.Add("Inventory c" & item.Inventoryc)
Next End If End If End Using Return Al End Function
- Edited by ALily Friday, February 15, 2013 11:30 PM Formatting.
All Replies
-
Friday, February 15, 2013 11:31 PM
Public Shared Function LoadInventoryItems(ByVal ProductId As String) As ArrayList to Public Shared Function LoadInventoryItems(ByVal ProductId As String) As StringBuilder.
-
Monday, February 18, 2013 1:38 AMModerator
Hi ALily,
Welcome to the MSDN forum.
Glad to know your problem is solved. Thank you for sharing.
Best Regards,
Alexander Sun [MSFT]
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

