public static void updateDB(string ippis, string message) { using (var context2 = new NominalDataEntities()) { //var result = context2.StaffDatas.SingleOrDefault(b => b.IppisNo == ippis); var result = context2.StaffDatas.FirstOrDefault(b => b.IppisNo == ippis); if (result != null) { result.Comment = message; context2.SaveChanges(); } } }
private static string dbaseAccess(string ippis, string token) //public static void dbaseAccess() { //IEnumerable<StaffData> query = DBAccess.StaffDatas.Select(); string finalValue; using (var context = new NominalDataEntities()) { var stdQuery = (from d in context.StaffDatas select new { Id = d.Id, PinNo = d.PinNo, IppisNo = d.IppisNo, Fullname = d.Fullname, EmailAddress = d.EmailAddress, Department = d.Department, Comment = d.Comment }).Where(x => x.IppisNo == ippis).FirstOrDefault(); /*foreach (var q in stdQuery) * { * Console.WriteLine("PinNo : " + q.PinNo + ", IppisNo : " + q.IppisNo + ", Department : " + q.Department); * }*/ //Console.ReadLine(); if (stdQuery != null && token == "email") { finalValue = stdQuery.EmailAddress; } else if (stdQuery != null && token == "name") { finalValue = stdQuery.Fullname; } else { finalValue = null; } } return(finalValue); }