Automatically bind column names when calling stored procedures in LINQ

Source: Internet
Author: User
Take the following stored procedure as follows:

Create procedure DBO. sp1
Select 'abc'

In C:
VaR o = dB. SP1 ();
Gridview1.datasource = O;
Gridview1.databind ();
No data is obtained.

The reason is that the SELECT statement does not specify a column name, while the LINQ query must contain a column name. However, if you only add a column name to the stored procedure, data still cannot be obtained because in dbdatacontext, the definition of the SP1 function has been bound to the original select function. You must delete the SP1 function and drag it from the database to obtain the data.

From this point of view, it is still a little inconvenient. If the technology can be used in the future, it will be better to automatically update Tables and stored procedures.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.