开发者

WCF RIA Services getting the ID of inserted row

I am using WCF RIA Services. I am not using entities and direct sql's. In my case stored procedures and complex types do all work. So I've faced with such a problem: when i use store procedure to insert a row,there is no way to automatically update its ID from the database. In case of using entity and direct sql everything goes well. Here is my stored procedure:

BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    insert into Product
    (       
       [Name]
      ,[Note]  )
      values
      (      
    @Name,
    @Note   
      )      
      select SCOPE_I开发者_开发百科DENTITY() as ID

END

The only way to solve this -is to reload all the data againg after the insert.I think it is not good idea to load all the data, when only the one row must be updated.Second approach is to write some more code to get the new id manually from the SQL Server, but i believe there must be a better approach.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜