本文介绍了如何使用ado.net实体数据模型执行更新和删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! Hai朋友, 我在wcf服务中使用ado.net实体数据模型进行插入,更新和删除。但我无法执行更新操作。我已经在下面发布了我的代码,所以请给你解决问题 Iwardservice.cs: [ServiceContract] public interface IWardService { [OperationContract] bool UpdateWard(WardMaster病房); } Wardservice.svc.cs: public bool UpdateWard(WardMaster病房) { WardConfig context = new WardConfig(); var wardToUpdate = context.Gema_WardSecond.First(p = > p .Wardid == ward.Wardid); if (wardToUpdate == null ) return false ; wardToUpdate.CompanyCode = ward.CompanyCode; wardToUpdate.Yearcode = ward.Yearcode; wardToUpdate.Wardid = ward.Wardid; wardToUpdate.WardName = ward.WardName; wardToUpdate.Remarks = ward.Remarks; wardToUpdate.ActiveFlag = Convert.ToByte(ward.ActiveFlag); wardToUpdate.CreatedBy = ward.CreatedBy; wardToUpdate.Createddate = ward.Createddate; wardToUpdate.ModifiedDate = ward.ModifiedDate; context.SaveChanges(); return true ; } 解决方案 Hai friends, I am using ado.net entity data model for insert,update and delete in wcf services . but i am unable to perform update operation . I have posted my code below so kindly give ur solnsIwardservice.cs:[ServiceContract] public interface IWardService { [OperationContract] bool UpdateWard(WardMaster ward); }Wardservice.svc.cs: public bool UpdateWard(WardMaster ward) { WardConfig context = new WardConfig(); var wardToUpdate = context.Gema_WardSecond.First(p => p.Wardid == ward.Wardid); if (wardToUpdate == null) return false; wardToUpdate.CompanyCode = ward.CompanyCode; wardToUpdate.Yearcode = ward.Yearcode; wardToUpdate.Wardid = ward.Wardid; wardToUpdate.WardName = ward.WardName; wardToUpdate.Remarks = ward.Remarks; wardToUpdate.ActiveFlag = Convert.ToByte(ward.ActiveFlag); wardToUpdate.CreatedBy = ward.CreatedBy; wardToUpdate.Createddate = ward.Createddate; wardToUpdate.ModifiedDate = ward.ModifiedDate; context.SaveChanges(); return true; } 解决方案 这篇关于如何使用ado.net实体数据模型执行更新和删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-04 05:35