Entity Framework执行sql语句:
Model.UnitOfWork.Current.ExecuteStoreCommand(
string.Format("update [User] set UserName='{0}',LastModifiedUser='{1}',updatedate='{2}' where UserName='{3}'", model.AlterID, GetLoginUserID, DateTime.Now,model.BeforeID)
);
Entity Framework执行sql存储过程:
int i = Model.UnitOfWork.Current.ExecuteStoreCommand(String.Format("exec proc_ChangeCardID @OldCardID='{0}',@NewCardID='{1}'", model.BeforeID, model.AlterID));
Entity Framework事务的使用方法:
Person person = new Person();
person.ID = IDNumbers.Value;
person.FullName = FullNames.Value;
person.BirthDate = Convert.ToDateTime(BirthDates.Value);
person.EmailAddress = EmailAddresss.Value;
person.MobileNumber = MobileNumbers.Value;
person.HomeAddress = HomeAddress.Value;
if (Sex.Checked == true)
{
person.SexName = "男";
}
else
{
person.SexName = "女";
}
person.CreateDate = DateTime.Now;
PersonCards personcard = new PersonCards();
personcard.PersonID = IDNumbers.Value;
personcard.CardID = this.GetCard.ID;
personcard.TypeID = TypeID.SelectedValue;
personcard.UpdateDate = DateTime.Now;
Model.UnitOfWork.Current.PersonCards.AddObject(personcard);
Model.UnitOfWork.Current.SaveChanges();