Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
This is my service:
C#
public string CloseDay(string date)
        {
            string Message = string.Empty;
            try
            {
                Session session = new Session();
                session.Status = "C";
                //db.Update<Session>(session.Status, a => a.SessionDate == Convert.ToDateTime(date));
                db.Update<Session>(session, a => a.SessionDate == Convert.ToDateTime(date));
                Message = "Day Closed Successfully";
            }
            catch (Exception Ex){ Message = Ex.Message; }
            return Message;
        }


My code is working but the problem is, it updates the whole row. I want it to update just one column. I tried passing just one column as you can see in the comment. But that throws an error.Please help..
Posted
Comments
Rajdeep Debnath 13-Dec-15 13:25pm    
Can you provide bit more detail on technology you are using to update like EF or nHibernate?
Member 11579819 13-Dec-15 13:32pm    
I am using ORM lite.. pretty similar to EF
Sinisa Hajnal 14-Dec-15 3:48am    
Why is it updating whole row a problem?
Member 11579819 14-Dec-15 4:13am    
As of now this ain't a big problem.. But there are some other big modules where am gonna face this issue again. So there it would be a problem for me.
xszaboj 14-Dec-15 4:44am    
and session.Status is object? Also you can always just write simple sql update instead of using ORM if you need something special, but i think it should be problem to update just one value. could you provide more info about Session object and table in db?

1 solution

Use Patch for patial update and AddRange for inserting multiple rows.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900