troubleshooting Question

LINQ SQL Query

Avatar of APE47
APE47Flag for United Kingdom of Great Britain and Northern Ireland asked on
Microsoft SQL Server.NET ProgrammingMicrosoft Development
4 Comments1 Solution352 ViewsLast Modified:
Hi,

I am trying to filter a set of data returned from a DataContext in Silverlight and I need to know how to combine the code below into a single statement.

I.E. If the CompanyID passed is Zero then all records should be returned, if it is greater than Zero then it should be filtered by the Company ID


      If CompanyID = 0 Then
        Return Me.DataContext.Medias.Where(Function(m) (m.CompanyID <> CompanyID))
      Else
        Return Me.DataContext.Medias.Where(Function(m) (m.CompanyID = CompanyID))
      End If

Thanks in advance

Tony
ASKER CERTIFIED SOLUTION
eridanix

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros