locked
stored procedure of insert statement is not displaying RRS feed

  • Question

  • User-1471881183 posted

    hi all,

    i have a web api 2 project, there im using ado.net entity framework. while creating EF i have included all my USP(stored procedures) too, among them 3 USP are only with select statements, 1 usp(namely usp_AddEmployee) is only with Insert statment. now the problem is select statement USP are displaying as Model class so, i could create controller but, when i try to create controller for usp_AddEmployee its, not showing model.

    so, i check in solution explorer there also no model file for usp_AddEmployee, i could understand the reason because, of insert statement only its not showing model.

    now, my question is how do i use this usp_AddEmployee in entity framework?

    experts please advise.

    Friday, June 8, 2018 1:16 PM

Answers

All replies

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 8, 2018 1:27 PM
  • User-1471881183 posted

    thank you Patrice

    above examples are showing straight forwards. but, in my situation the insert sp has many string parameters but, inside of the SP i'll find the ID of those data from lookup tables. in this situation can you please tell me how do we map because, SP input parameters are string but, actual table has INT columns

    below is my sp structure

    Create PROCEDURE [dbo].[usp_AddData]

    (

     @Data1 varchar(50),   @Data2 varchar(50),  @Data3 varchar(50),

    )

    ..........

    Find the ID of all @Data and pass them into the table

    End of USP

    below is my table format

    ID int Primary Key Identity(1,1)

    Data1 int not null (FK of tlkpData1 table)

    Data2 int not null (FK of tlkpData2 table)

    Data3 int not null (FK of tlkpData3 table)

    can you please guide me?

    Monday, June 11, 2018 10:47 AM
  • User1724605321 posted

    Hi winseealn,

    I am not sure that i have understand your scenario . But if you want to find a way to convert text to number SQL Server script , you can try :

    In SQL Server 2005/2008 :

    Declare @string as varchar(5)
    Set @string ='12345'
     
    Select Convert(int,@string) as [Convert Text to Integer]
    Select Cast(@string as int) as [Cast Text to Integer]
     
    --RESULT
    Convert Text to Integer
    -----------------------
    12345
     
    (1 row(s) affected)
     
    Cast Text to Integer
    --------------------
    12345
     
    (1 row(s) affected)
    Example 2 : (Convert Te

    In SQL Server 2012 :

    Declare @string as varchar(5)
    Set @string ='12345'
     
    Select Try_Convert(int,@string) as [Convert Text to Integer]
    Select Try_Cast(@string as int) as [Cast Text to Integer]
     
    --RESULT
    Convert Text to Integer
    -----------------------
    12345
     
    (1 row(s) affected)
     
    Cast Text to Integer
    --------------------
    12345
     
    (1 row(s) affected)

    Best Regards,

    Nan Yu

    Tuesday, June 12, 2018 6:25 AM