dotConnect for Oracle 9.4.348, .net core 1.1, ef - execute a stored procedure

dotConnect for Oracle 9.4.348, .net core 1.1, ef - execute a stored procedure

Postby jarun » Sun 29 Oct 2017 19:19

I have installed the trial version dotConnect for Oracle 9.4.348. I am trying to use EF Core. When I execute a procedure without parameter, everything works, when I try to execute a procedure with parameter, I get an exception.
What is wrong?

Code: Select all
using Microsoft.EntityFrameworkCore;
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var context = new ModelContext();

            try
            {
                Console.WriteLine("--== Test 1 ==--");

                context.Test(100);

                Console.WriteLine("--== Test 1 ok ==--");
            }
            catch (Exception ex)
            {
                Console.WriteLine("--== Test 1 excepttion ==--");

                Console.WriteLine($"{ex.Message}\n{ex.StackTrace}");

                Console.WriteLine("--== Test 1 excepttion ==--");
            }

            Console.WriteLine("\n\n\n");

            try
            {
                Console.WriteLine("--== Test 2 ==--");

                context.Test(200);

                Console.WriteLine("--== Test 2 ok ==--");
            }
            catch (Exception ex)
            {
                Console.WriteLine("--== Test 2 excepttion ==--");

                Console.WriteLine($"{ex.Message}\n{ex.StackTrace}");

                Console.WriteLine("--== Test 2 excepttion ==--");
            }

            Console.ReadKey();
        }
    }

    public class ModelContext : DbContext
    {
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            var builder = new Devart.Data.Oracle.OracleConnectionStringBuilder();
            builder.Direct = true;
            builder.Server = "";
            builder.Sid = "";
            builder.UserId = "";
            builder.Password = "";
            optionsBuilder.UseOracle(builder.ConnectionString, null);
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {

        }

        public void Test(int id)
        {
            if (id.Equals(100))
            {
                this.Database.ExecuteSqlCommand("begin testowner.temp_proc(100); end;");
            }
            else
            {
                this.Database.ExecuteSqlCommand("BEGIN testowner.temp_proc(:p); END;",
                    new Devart.Data.Oracle.OracleParameter[]
                    {
                        new Devart.Data.Oracle.OracleParameter("p", Devart.Data.Oracle.OracleDbType.Number, id, System.Data.ParameterDirection.Input)
                    }
                    );
            }
        }
    }
}


Code: Select all
--== Test 1 ==--
--== Test 1 ok ==--

--== Test 2 ==--
--== Test 2 excepttion ==--
Object reference not set to an instance of an object.
   at Devart.Data.Oracle.Entity.bb.a(IEnumerable`1 A_0, cq A_1)
   at Devart.Data.Oracle.Entity.ah.i()
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, String executeMethod, IReadOnlyDictionary`2 parameterValues, Boolean closeConnection)
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)
   at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.ExecuteSqlCommand(DatabaseFacade databaseFacade, String sql, Object[] parameters)
   at ConsoleApp1.ModelContext.Test(Int32 id) in C:\ConsoleApp2\Program.cs:line 78
   at ConsoleApp1.Program.Main(String[] args) in C:\ConsoleApp2\Program.cs:line 35
--== Test 2 excepttion ==--
jarun
 
Posts: 2
Joined: Fri 06 Oct 2017 05:21

Re: dotConnect for Oracle 9.4.348, .net core 1.1, ef - execute a stored procedure

Postby Shalex » Wed 01 Nov 2017 14:27

Thank you for your report. We have reproduced the issue and are investigating it. We will notify you when it is fixed.
Shalex
Devart Team
 
Posts: 7780
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for Oracle