---
# System prepended metadata

title: 預存程序sp
tags: [c#, mvc, 火箭]

---

# 預存程序sp
###### tags: `火箭` `c#` `mvc`

entityframwork版本
```csharp=
public bool AddMember()
        {
            BackendContext db = new BackendContext();
            var pid = new SqlParameter { ParameterName = "Id", Value = 0, Direction = ParameterDirection.Output };
            var result =
                db.Members.SqlQuery(
                    "dbo.CreateMember @Account,@Password,@PasswordSalt,@Name,@Email,@JobTitle,@Permission,@Poster,@UnitId,@Gender,@MyPic,@Id out",
                    new SqlParameter("Account", this.Account), new SqlParameter("Password", this.Password),
                    new SqlParameter("@PasswordSalt", this.PasswordSalt),
                    new SqlParameter("Name", this.Name),
                    new SqlParameter("Email", this.Email), new SqlParameter("JobTitle", this.JobTitle),
                    new SqlParameter("Permission", this.Permission),
                    new SqlParameter("Poster", "admin"), new SqlParameter("UnitId", this.UnitId),
                    new SqlParameter("Gender", this.Gender),
                    new SqlParameter("MyPic", this.MyPic ?? ""), pid).SingleOrDefault();
            return pid.Value.ToString() != "0";
        }
```