Happy with that. Thomas
On Nov 16, 7:44 pm, Jonathan Pryor <[email protected]> wrote: > On Sat, 2009-11-14 at 06:28 -0800, Thomas Glaser wrote: > > The following method in src/DbLinq/Data/Linq/Sugar/ > > ParameterizedQuery.cs seems to cause a problem on Mono 2.4.2.3: > > > private object NormalizeDbType(object value) > > { > > System.Data.Linq.Binary b = value as System.Data.Linq.Binary; > > if (b != null) > > return b.ToArray(); > > return value; > > } > > > The line "if (b != null)" causes a "System.NotImplementedException". > > "value" contained a string. This is quite probably a bug in Mono > > Upon investigating, I've found the culprits: > > 1. Binary overloads the operator== and operator!= operators (wtf?!). > 2. Mono 2.4.2.3 doesn't have a "real" System.Data.Linq.dll (just > stubs); consequently: > > [MonoTODO] > public static bool operator == (Binary binary1, Binary binary2) > { > throw new NotImplementedException (); > } > 3. When mono shows stack traces, it's apparently now showing > the operator== in the stack trace (possibly because of inlining). > > Thus, the 'value as Binary' works, and is null, but > Binary.op_Equality(b, null) throws a NotImplementedException, which is > what you see. The fix of using 'is' + 'as' works around this, as it > completely skips the Binary.op_Equality() call. > > I never thought I'd hate an overloaded operator==()... > > Consequently, the simple fix should be to avoid the problematic > operator==(): > > var b = value as Binary; > // Mono 2.4.2.3's Binary.operator!= is bad; avoid it. > if (!object.ReferenceEquals(b, null)) > return b.ToArray(); > return value; > > Does that work for you? > > - Jon -- You received this message because you are subscribed to the Google Groups "DbLinq" group. To post to this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/dblinq?hl=.
