What's the advantage of displaying a binary column in System.Data.Linq.Binary instead of byte []?

LINQ to SQL maps a binary column (varbinary, image, ...) to a property of type "System.Data.Linq.Binary" by default. Working with binary data is not that hard, but you can manually change this mapping to "byte []", which makes it easier to work with binary data (since you no longer need to convert it to code.

What is the disadvantage of this? Why was the default binary type selected for these column types. Why does a binary type even exist? I am guessing that using a binary type for some reason allows you to "lazy load" the binary data, but this is just my guess and I cannot find any documentation to support this.

Does anyone else have any information on this?

UPDATE:

According to this blogpost , the way to make a binary function lazy is to set the "delay loaded" property to True, which turns the datatype property into a link. This would mean that a regular binary property does not do lazy loading by itself. So my question remains a fact: what advantage does a binary with byte [] have?

+2


source to share


1 answer


I found this mention here :



The binary type exists because LINQ to SQL cannot keep track of changes made to byte []. It only keeps track of the changes made to the property when you assign a new byte []. Binary type is an immutable version of byte [], just like String type is an immutable version of char []. Since you cannot change the contents of a binary type, the only way to change it is by assigning a property to a new instance.

+1


source







All Articles