public void DeletePrice(List <string> lstSymbole) { try { using (var unitOfWork = new EFUnitOfWork()) { var priceRepo = new PriceRepository(new EFRepository <Price>(), unitOfWork); ObjectSet <Price> priceObj = ((CurrentDeskClientsEntities)priceRepo.Repository.UnitOfWork.Context).Prices; var lstPrice = priceObj.Where(p => lstSymbole.Contains(p.Symbole)).ToList(); foreach (var price in lstPrice) { priceRepo.Delete(price); } priceRepo.Save(); } } catch (Exception ex) { CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); } }
// Add your own data access methods here. If you wish to // expose your public method to a WCF service, marked them with // the attribute [NCPublish], and another T4 template will generate your service contract public void DeleteSymbol(string symbole) { try { using (var unitOfWork = new EFUnitOfWork()) { var priceRepo = new PriceRepository(new EFRepository <Price>(), unitOfWork); ObjectSet <Price> priceObj = ((CurrentDeskClientsEntities)priceRepo.Repository.UnitOfWork.Context).Prices; var price = priceObj.Where(s => s.Symbole == symbole).FirstOrDefault(); if (price != null) { priceRepo.Delete(price); priceRepo.Save(); } } } catch (Exception ex) { CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); } }