我有一个这样的存储过程:
@uName nvarchar(20),
@password nvarchar(50)
AS
IF NOT EXISTS(SELECT UserName FROM Members WHERE UserName = @uName)
BEGIN
INSERT INTO Members(UserName, Password) VALUES (@uName, @password)
END
此存储过程映射到我的Members
实体,并由EF隐式调用。
如何确定是否插入了行?
using (var context = new BlogEntities())
{
var member = new Member()
{
UserName = "Blah",
Password = "Blah"
};
int affected = context.SaveChanges();
}
变量affected
始终返回1
!