我在 Asp.net 中遇到实体框架问题。每当我向 SQL 数据库表添加记录时,我都想获取 Id 值。我怎样才能做到这一点?这是我的代码:StoredProcedure USE [Sapphiresworld]GO/****** Object: StoredProcedure [dbo].[addProduct] Script Date: 7/4/2018 10:25:41 AM ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER Proc [dbo].[addProduct]@title nvarchar(250),@price nvarchar(50),@unitID int,@date nvarchar(50),@subCategoryID int,@brandID int,@vat int,@discount int,@picture nvarchar(50),@stock intasdeclare @MyVal int=0INSERT into [PRODUCT] values (@title,@price ,@unitID,@date,@subCategoryID ,@brandID ,@vat ,@discount ,@picture ,@stock)Set @MyVal = @@IDENTITYSelect @MyVal as Val这里是 ClsBrand public string AddBrand(string brandName) { var result = new SapphiresworldEntities().AddBrand(brandName).ToString(); return result; }针对保存按钮的代码 protected void Btnsave_Click(object sender, EventArgs e){ clsBrand nb = new clsBrand(); string nwBran = nb.AddBrand(relig.Text);}
添加回答
举报
0/150
提交
取消