Updating selected fields with linq to sql

I have been writing a bunch of stuff in asp.net mvc of late and have been using linq to SQL to quickly pull together my DAL (although I have been using a repository pattern and castle Windsor to implement an IOC container which I picked up from the excellent pro asp.net mvc book). One of my entities is a profile object and, on editing, I only wanted to update the image field if the user uploaded a new image. After struggling to skip the field with linq I found I could select the old profile object from the data context and simply update the other fields declaratively if no Image is passed in the new profile object. I can’t help feeling there is a more elegant way of doing this but I have had to be pragmatic and implement this as it works. I’ll post the code shortly.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s