Hi All,
Can someone give me an example on how to write nested select statement using LinQ.
Regards,
Varsha BS
Hi All,
Can someone give me an example on how to write nested select statement using LinQ.
Regards,
Varsha BS
@varsha.bs
Welcome to the Forum
Please Share more Details with us. Can you Post some Sample Data and expected Output description. Thanks
Hi
I need to write below query using LinQ.
Select TOP 5 ProcessFlowTable.ProcessFlowGroup,(Select Stages.StageName from Stages where Stages.ProcessFlowGroup = â1â) as ProcessFlowStage,ProcessFlowTable.ProcessFlowStep,ProcessFlowTable.ProcessFlowShape,ProcessFlowTable.ProcessFlowShape as ShapeStyleSheet,ProcessFlowTable.ProcessFlowStep, ProcessFlowTable.ProcessFlowLabel,â+strStepSelected+â as StepSelected from ProcessFlowTable where ProcessFlowTable.ProcessFlowGroup = â1â
Thanks
Varsha BS
@varsha.bs
Kindly note: LINQ is not SQL
However can you please give some details on requirements. It looks like a databse query
Hi,
Yes this is a Database query and I need to convert to LinQ query. I have done almost and only thing which is not working is the select statement which is inside the Select.
So I need a help on this.
Below is the LinQ that I have done for the above SQL.
(From p In In_dtProcessFlowTable.AsEnumerable()
Where Convert.ToString(p(âProcessFlowGroupâ))=â1â
Select dtTempTable.LoadDataRow(New Object() {p.Field(Of Double)(âProcessFlowGroupâ),(From s In In_dtStages Where Convert.ToString(s(âProcessFlowGroupâ))=â1â Select s.Field(Of String)(âStageNameâ)),p.Field(Of String)(âProcessFlowStepâ),p.Field(Of String)(âProcessFlowShapeâ),p.Field(Of String)(âProcessFlowShapeâ),p.Field(Of String)(âProcessFlowStepâ),p.Field(Of String)(âProcessFlowLabelâ)},False)).Take(5).CopyToDataTable
Actual Output: I am getting below output for nested select
System.Data.EnumerableRowCollection`1[System.String]
Expected Output: I need to get the string value
Regards
Varsha BS
some details are hidden to me. However to start have a look on the rearranged LINQ
(From p In In_dtProcessFlowTable.AsEnumerable()
Where p(âProcessFlowGroupâ).toString.Equals(â1â)
Let ProcessFlowStage = In_dtStages.AsEnumerable.Where(Function (ds) ds("ProcessFlowGroup").toString.Equals("1"))
Let ra = New Object(){
p("ProcessFlowGroup"),
ProcessFlowStage,
p(âProcessFlowStepâ),
p(âProcessFlowShapeâ)
}
Select dtTempTable.Rows.Add(ra)).Take(5).CopyToDataTable
Respect the line breaks and just complete the column list from the object Array. Maybe you get it running or we go into a next iteration.
Kindly note: LINQ is different from SQL
Help you can find here:
and sure here in the forum we are here for helping you
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.