I'm familiar with t-sql but not in LINQ, I had tried basic linq but not sure on this one. Im not sure if there's an exact equivalent in linq on my written sql statement below. Basically I want to transfer the linq result to my domain model.
The sql query are using the same view (1 sql view)
Domain Model
Public class Result
{
Public int Key{get;set;}
Public string Name{get;set;}
}
SQL Query
SELECT DISTINCT Name = Field1 ,ItemKey = Field2 FROM sql_view
UNION
SELECT DISTINCT Name = Field3 ,ItemKey = Field4 FROM sql_view
UNION
SELECT DISTINCT Name = Field5 ,ItemKey = Field6 FROM sql_view
UNION
SELECT Name = Field7 ,ItemKey = Field8 FROM sql_view
Sample Data of sql_vw
Field1 Field2 Field3 Field4 Field5 Field6 Field7 Field8
1 A1 23 FF23 322 ZZ322 10 A10
1 A1 23 FF23 322 ZZ322 21 R21
1 A1 23 FF23 322 ZZ322 31 E31
2 B2 22 PP22 331 WW331 3 A3
2 B2 22 PP22 331 WW331 7 R7
2 B2 22 PP22 331 WW331 9 E9
2 B2 22 PP22 331 WW331 12 E12
3 C3 26 HH26 340 NN340 43 H43
3 C3 26 HH26 340 NN340 39 J39