SubSonic-3.0 icon indicating copy to clipboard operation
SubSonic-3.0 copied to clipboard

Update where a property is set to null isn't translated correctly.

Open lievencardoen opened this issue 14 years ago • 0 comments

Next Update crashes because the x => x.Name == null will be translated to a Comparison.Is. As a consequence, in Update.cs, a InvalidOperationException is thrown saying 'Can't use a non-equality here'.

In the Where part, this would be correct but in the Set part it should be translated to a Comparison.Equals.

var affectedRecords = Db.Update<Schedule>()
.Set(x => x.Name == null, 
x => x.Description == entity.description)
.Where(x => x.ScheduleId == entity.id && x.Version == entity.version)
.Execute();

I solved this by adding a line in the Set method in Update.cs before the check on equality comparison.

if (c.Comparison == Comparison.Is) c.Comparison = Comparison.Equals;

lievencardoen avatar Dec 22 '10 11:12 lievencardoen