سؤال

In the method below db.SubmitChanges is shown as invalid/not recognized by intellisense. This is my first attempt to update records in a database using LINQ and the method may contain other logic/syntactical errors that I havent yet uncovered as well. What is causing the SubmitChanges to be incorrect?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.ComponentModel.DataAnnotations;
using System.Linq.Expressions; 

public void updateInfo(RefillViewModel _myRefillViewModel)     {                 
     try         {
         decimal patid = _myRefillViewModel.Patient.Patient_ID;
         decimal rxid = _myRefillViewModel.Rx.Rx_ID;

         CAHODEntities db = new CAHODEntities();

         List<Fill> FillList = db.Fills.Where(p => p.Rx.Rx_ID == rxid && p.Rx.Patient_ID == patid && p.Status == "UnFilled").ToList();

         foreach (var item in FillList)
         {
             if (FillList.Count() == 0)
             {
                 item.Status = "Requested";
             }
         }
         db.SubmitChanges();
     }
}    
هل كانت مفيدة؟

المحلول

Are you using EF? Because in Entity Framework it's SaveChanges() not SubmitChanges().

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top