0

I am trying to perform bulk copy for into a table that has few fields that are of type "float" in MS SQL Server. I noticed that after bulk copy completed, all these "Float" fields had value of "NULL". These fields allowed null value so these NULLs were there. I traced the call in SQL Profiler and noticed that "INSERT BULK" command did not have these "float" fields. I simplified my case to just simple object as below.

public class TestIt
    {
        public int Id{get;set;}
        public string Title { get; set; } = $"Title{DateTime.UtcNow}";
        public double? Price { get; set; }
    }

The table has following schema.

CREATE TABLE [dbo].[TestIt](
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [Title] [nvarchar](50) NULL,
    [Price] [float] NULL,
 CONSTRAINT [PK_TestIt] PRIMARY KEY CLUSTERED 
(
    [Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

When I execute BulkCopy for a list of these object, I can see that "Title" field was copied correctly. Where was "Price" field always have NULL.

Is this some limitation in Linq2Db or I am doing something wrong.

When I use bulk copy with EF, it works fine.

ByteBlocks
  • 607
  • 3
  • 9
  • 24

0 Answers0