Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ODP.NET 18.3 Bulkinsert with Nullable Types

user10709180Jan 2 2019 — edited Mar 11 2019

I'm trying to get bulkinsert working in a .NET application.

I have a lot of string columns, a few int columns that al seem to work when my data POCO properties are of string or int.

The bulk insert fails to work when I try to insert a Nullable int (int?) as source! Which I didn't expect as the column in the table is nullable, and should be able to handle null.

Mind you, although the POCO property was int?, it had values for all rows the array I extracted from it. So it couldn't be a <null> problem.

The exception 'System.ArgumentException' (Value does not fall within the expected range) is thrown when I try to add the array to the Parameter property of the command. (So we don't even get to the database).

I'm using ODP.NET 18.3 as dataprovider. The application is written in C# 3.5.

So I have the following questions:

1) Can I use a Nullable type (int?, datetime?) in ODP.NET BulkInsert?

2) If the answer to the previous anwer is a yes, what should I take in consideration? What am I missing?

POCO

public class MyPoco

{

        public int? MyInt { get; set; }

}

The code that extracts the array of values.

                // Get the list of values (as object)

                var valueObjectList = dataEntityList

                    .Select(item => propInfo.GetValue(item))

                    .ToList();

                var parameter = command.CreateParameter();

                parameter.Direction = ParameterDirection.Input;

                parameter.IsNullable = true;

                parameter.ParameterName = ":" + propInfo.Name;

                dynamic result = null;

                if (propertyType == typeof(int?))

                {

                    result = ConvertToTypedList<int?>(valueObjectList);

                    parameter.Value = result; <----- this gives an ArgumentException

               // More code that is unimportant.

'result' had values in it!

Regards

Marc

Comments
Post Details
Added on Jan 2 2019
4 comments
639 views