LINQ Query : How to return a single value from a stored procedure

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • psycho

    LINQ Query : How to return a single value from a stored procedure

    How do we return a single value from a stored procedure.

    Suppose I have a stored procedure like this:

    create proc dbo.spInsertGro up
    @ID uniqueidentifie r
    @GroupName varchar(100),
    @IsActive bit
    AS
    BEGIN

    SET @ID = newid()

    insert into tblGroup
    values(@ID, @GroupName, @IsActive)

    select @ID

    END

    i am trying to return the same value using LINQ to SQL using stored
    procedure.
    But all the methods are failing as those types do not have a default
    constructor

    Is there any method by which i can perform this task.


  • =?Utf-8?B?YnJ1Y2UgYmFya2Vy?=

    #2
    RE: LINQ Query : How to return a single value from a stored procedure

    LINQ does not support stored procedure. the LINQ to SQL data designer
    supports adding stored procedure calls as methods to a data context. the
    return value will be a collection of values. you will need to write your own
    method if you just want a single return value.

    -- bruce (sqlwork.com)


    "psycho" wrote:
    How do we return a single value from a stored procedure.
    >
    Suppose I have a stored procedure like this:
    >
    create proc dbo.spInsertGro up
    @ID uniqueidentifie r
    @GroupName varchar(100),
    @IsActive bit
    AS
    BEGIN
    >
    SET @ID = newid()
    >
    insert into tblGroup
    values(@ID, @GroupName, @IsActive)
    >
    select @ID
    >
    END
    >
    i am trying to return the same value using LINQ to SQL using stored
    procedure.
    But all the methods are failing as those types do not have a default
    constructor
    >
    Is there any method by which i can perform this task.
    >
    >
    >

    Comment

    Working...