How does one query a SQL View with Linq to SQL?
-
24-10-2019 - |
Question
I normally do something like this...
var theDogs = from d in db.Dogs where d.Equals(5) select d;
//LetThemOut(theDogs);
where db is the DataContext and Dogs is a table, but what about a View?
Is it the same?
Solution
Yes, it is the same. You just can't insert/update/delete data in a view.
If you're using the LINQ to SQL designer, just drag the view to the DBML designer.
If you're using a manual mapping, just map the object you are defining to a view, instead of a table.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow