probably another rookie mistake, but I am having problems running through a loop to update multiple values.

I am returning a value (a date time - tTS) from a form and using to query a table. That part works fine... to a point. I am building this out in steps, proving each works and moving on to the next. I started with the query returning .FirstOrDefault and that worked and updated the record, so the query works fine otherwise. To retrieve multiple items and update each have tried .ToList() and foreach()...

var holidaytest = db.HolidayTest
                    .Where(x => x.TimeStamp == tTS)

foreach(var item in holidaytest)
    holidaytest.DecimalT = (29.5);


I have tried numerous variations of the above but keep getting a red line under .DecimalT: 'System.Collections.Generic.List' does not contain a definition for 'DecimalT' and no extension method 'DecimalT' accepting the first argument of type 'System.Collections.Generic.List' could be found (are you missing a using directive or an assembly reference?) I am using:

using HolidaysDev.Models
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

Just for reference, I am trying to set DecimalT to (29.5) for testing, I will change this stage is working properly - figured it was easier working with a static value.

Related posts

Recent Viewed