igor-tkachev / bltoolkit

Business Logic Toolkit for .NET
MIT License
297 stars 112 forks source link

Insert fails for array field #363

Closed Firebie closed 9 years ago

Firebie commented 9 years ago

Insert fails for class array property fields (i.e. byte[])

/*
-- Sql Server
create table TestByte
(
  data image
)
*/
  public class TestByte
  {
    public byte[] data;
  }

  using (var db = new DbManager())
  {
    db.Into(db.GetTable<TestByte>())
      .Value(i => i.data, new byte[] {1, 2, 3})
      .Insert();
  }

Fix:

diff --git BLToolkit.4/Data/Linq/Builder/UpdateBuilder.cs w/BLToolkit.4/Data/Linq/Builder/UpdateBuilder.cs index 1c398fb..62cf6e4 100644 --- i/BLToolkit.4/Data/Linq/Builder/UpdateBuilder.cs +++ w/BLToolkit.4/Data/Linq/Builder/UpdateBuilder.cs @@ -391,7 +391,7 @@ namespace BLToolkit.Data.Linq.Builder var memberAccessor = TypeAccessor.GetAccessor(member.DeclaringType)[member.Name]; sqlValue.SetEnumConverter(memberAccessor, builder.MappingSchema); }

ghost commented 9 years ago

It is strange... I just tested 3 different versions: 1) My own fork - works fine! 2) Last nuget package (4.2.0) - works fine! 3) Latest version compiled from original repository - failed!

Database Server: SQL Server 2012

jogibear9988 commented 9 years ago

maybe same issue I have here: https://github.com/igor-tkachev/bltoolkit/issues/360