0

I need to use stored procedure to get data from DB, but I would also like to use IQueryable to add some filtering to results. I'm using subsonic and for now can't see a way to use subsonic sp and IQueryable. The only idea I have is to make a view that will perform all required joins. Then perform call to view like to table with subsonic:

MyView.All()

Subsonic All returns IQueryable and instead of adding where in sp I can add filter clauses in code. Not sure if this is viable solution or not?

Henrik
  • 23,186
  • 6
  • 42
  • 92
Yaroslav Yakovlev
  • 6,303
  • 6
  • 39
  • 59

2 Answers2

1

IQueryable allows translating LINQ queries into SQL statements. Using IQueryable in conjunction with stored procedures is the same as mixing a SQL statement with a stored procedure, such as SELECT * FROM dbo.MyStoredProc WHERE x > 100. Since this won't work, mixing IQueryable with a stored procedure is useless, because there is no way to filter the results of the SP before they return.

What you are looking for is client-side (.NET side) filtering. For this you can simply use IEnumerable. When your stored procedure returns a collection of items, you can still use LINQ queries over that collection.

Steven
  • 166,672
  • 24
  • 332
  • 435
0

Ok, I`ve finished with this solution to add views to my SubSonic objects and IQueryable to add filtering.

Community
  • 1
  • 1
Yaroslav Yakovlev
  • 6,303
  • 6
  • 39
  • 59