Question

I am trying to change NULL values of a column in the database to its previous non-null value and save it in the database through a Linq|lambda query, have Entityframework 5.0 with MS-SQl server2012. example:

Time Temperature
11:00 23
12:00 23
13:00 23
14:00 NULL
15:00 23
16:00 NULL
17:00 NULL
18:00 23
19:00 23

to

Time Value
11:00 23
12:00 23
13:00 23
14:00 23
15:00 23
16:00 23
17:00 23
18:00 23
19:00 23

Exampe for SQL is here: (SQL QUERY replace NULL value in a row with a value from the previous known value)

No correct solution

OTHER TIPS

you try to do 2 things at the same time here. - Fetch data - Change data

I would split that up. -First get the data where temperature == null -then iterate over the results and set the values

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top