VB examples please
I need to return the same results from linq as I get using SQL
SELECT DISTINCT Area, Region
FROM dbo.Regions
Union
SELECT null,’All’
Order by 1,2
I use this for showing an “All” selecting in a combo box
My current linq points to a view that does the union for me but I want to know how to do it right in linq. I can’t figure out how to union a row for the null,’All’ values.
Public Shared Function GetRegions(ByVal Area As String) As IEnumerable
Dim DB As New SiteDBDataContext
Return From values In DB.uv_Areas _
Where values.Area = Area Or Area = "" Or values.Area Is Nothing _
Order By values.Region _
Select values.Area, values,Region
End Function
Thanks
You can’t do it in the DB with Linq to SQL or Entity Framework, but you can do it in memory with Linq to Objects: