I have a query to update a record; it looks somewhat like this:
public void SaveRecord(int TheUserID, Nullable<DateTime> TheDate,
Nullable<int> TheAction)
{
using DC...
{
var TheRecordToUpdate = (from....where ....
select l).Single();
TheRecordToUpdate.TheDate = TheDate;
TheRecordToUpdate.TheAction = TheAction;
TheDC.SubmitChanges();
The problem is that sometimes I supply null parameters and when that’s the case, I don’t want to change the field in the DB. How do I use the ?? operator in linq-to-sql when the parameter is null?
Thanks.
you can use the
??operatoror if you want to write it more explicitly
if
TheRecordToUpdate.TheDateis not a nullable property however, you’ll have to write