LINQ to SQL Advanced Series (v) Store procedure Articles

Source: Internet
Author: User

Store Procedure, stored procedures. It's something that someone else has written. I habitually see what others have written before I begin to see what I have to write. So let's talk about the difference between it and the UDF.

In the LINQ to SQL Advanced Series (d) User Define function article, we mentioned the difference between the two. For example, store procedure support multiple rowset, and UDF is not. They also have some other differences. Store procedure can only return an integer, and the UDF may be other types, such as Char, which, except for individual types, such as the imager type, are not allowed to be the return type of the UDF. The Store procedure supports out parameter and the UDF does not.

1, Singleresultset

Let's take a look at this sprocs first.

CREATE PROCEDURE [dbo].[Customers By City]
    -- Add the parameters for the stored procedure here
    (@param1 NVARCHAR(20))
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
    SELECT CustomerID, ContactName, CompanyName, City from Customers as c where c.City=@param1
END

Its generated code is as follows.

[Function(Name="dbo.[Customers By City]")]
public ISingleResult<Customers_By_CityResult> Customers_By_City([Parameter (DbType="NVarChar(20)")] string param1)
{
  IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo) (MethodInfo.GetCurrentMethod())), param1);
  return ((ISingleResult<Customers_By_CityResult>)(result.ReturnValue));
}

Here Customers_by_cityresult is the sprocs of this kind of innuendo. But you can adjust it in or designer. As pictured,

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: info-contact@alibabacloud.com 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.