Why are stored procedures, functions, and views put into a .dbml file instead of the code file for LINQ to SQL? How do you run stored procedures from a .dbml file?
Why are stored procedures , functions, and views put into a .dbml file instead
Share
They are put into a code file. The .dbml file is just the graphical representation that makes it easier for programmers to interface with those objects. If you look at all files in your solution you should notice a .dbml.layout file and a .designer.cs file. The designer file will contain the actual code that holds the object definitions, relationships, etc.
It is not recommended to edit this file directly, it is intended to auto-generate from the database directly.
Edit: To use a stored proc, you would drag it into your .dbml interface from the server explorer and then call it like this from within code.
This pseudo-code assumes you have the appropriate context defined as
myDbmlContext. Properly this would be done within the boundaries of a using block.