- 3,715,654 Users
- 2,242,820 Discussions
- 7,845,479 Comments
Forum Stats
Discussions
Categories
- 17 Data
- 362.2K Big Data Appliance
- 7 Data Science
- 1.6K Databases
- 467 General Database Discussions
- 3.7K Java and JavaScript in the Database
- 22 Multilingual Engine
- 487 MySQL Community Space
- 3 NoSQL Database
- 7.6K Oracle Database Express Edition (XE)
- 2.8K ORDS, SODA & JSON in the Database
- 416 SQLcl
- 42 SQL Developer Data Modeler
- 184.8K SQL & PL/SQL
- 21K SQL Developer
- 1.9K Development
- 3 Developer Projects
- 32 Programming Languages
- 135.1K Development Tools
- 8 DevOps
- 3K QA/Testing
- 247 Java
- 5 Java Learning Subscription
- 10 Database Connectivity
- 66 Java Community Process
- 1 Java 25
- 9 Java APIs
- 141.1K Java Development Tools
- 6 Java EE (Java Enterprise Edition)
- 153K Java Essentials
- 135 Java 8 Questions
- 86.2K Java Programming
- 270 Java Lambda MOOC
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 10 Java SE
- 13.8K Java Security
- 3 Java User Groups
- 22 JavaScript - Nashorn
- 18 Programs
- 125 LiveLabs
- 30 Workshops
- 9 Software
- 3 Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 3 Deutsche Oracle Community
- 10 Español
- 1.9K Japanese
- 2 Portuguese
Procedure refcursor null and array empty

I have a query via procedure in oracle where he returns me a refcursor with some blank columns (null), so far so good always did so and never had problems, however from the version of
.NET core 3.1 with Oracle.EntityFrameworkCore 2.19. 60 columns that should come blank (null) are coming with {} as if they were a blank object. How to solve it?
Thanks.
Answers
-
I haven't seen this issue before. Do you have a simple test case that reproduces the problem? Are you using EF Core 3?
-
Alex,
I'm sending a use case
Return Json:
[
{
"ID_FAIXA": 1,
"FAIXA_INICIAL": {},
"FAIXA_FINAL": 89.999,
"TARGET": 0
},
{
"ID_FAIXA": 2,
"FAIXA_INICIAL": 90,
"FAIXA_FINAL": 99.999,
"TARGET": 50
},
{
"ID_FAIXA": 3,
"FAIXA_INICIAL": 100,
"FAIXA_FINAL": 104.999,
"TARGET": 100
},
{
"ID_FAIXA": 4,
"FAIXA_INICIAL": 105,
"FAIXA_FINAL": 109.999,
"TARGET": 110
},
{
"ID_FAIXA": 5,
"FAIXA_INICIAL": 110,
"FAIXA_FINAL": 112.499,
"TARGET": 120
},
{
"ID_FAIXA": 6,
"FAIXA_INICIAL": 112.5,
"FAIXA_FINAL": 124.999,
"TARGET": 125
},
{
"ID_FAIXA": 7,
"FAIXA_INICIAL": 125,
"FAIXA_FINAL": 137.499,
"TARGET": 150
},
{
"ID_FAIXA": 8,
"FAIXA_INICIAL": 137.5,
"FAIXA_FINAL": 149.999,
"TARGET": 175
},
{
"ID_FAIXA": 9,
"FAIXA_INICIAL": 150,
"FAIXA_FINAL": {},
"TARGET": 200
}
]
Query:
public async Task<DbDataReader> ExecutaProcedureAsync(string storeProcedureName, OracleParameter[] oracleParameterValues, ConfiguracoesOracle.Linguagem linguagemConfigOracle = ConfiguracoesOracle.Linguagem.Americano)
{
try
{
if (Con.State == ConnectionState.Closed)
Con.Open();
Transaction = Con.BeginTransaction(IsolationLevel.ReadCommitted);
var globalOracle = ConfiguracoesOracle.SetOracleGlobalization(Con.GetSessionInfo(), linguagemConfigOracle);
if (globalOracle != null)
Con.SetSessionInfo(globalOracle);
using (Cmd = new OracleCommand(storeProcedureName, Con)
{
CommandType = CommandType.StoredProcedure,
Transaction = Transaction
})
{
if (Cmd.Parameters.Count == 0)
{
Cmd.Parameters.Clear();
if (oracleParameterValues != null)
{
foreach (var p in oracleParameterValues)
{
if ((p.Direction == ParameterDirection.InputOutput) && (p.Value == null))
{
p.Value = DBNull.Value;
}
Cmd.Parameters.Add(p);
}
}
}
var odr = await Cmd.ExecuteReaderAsync();
Transaction.Commit();
return odr;
}
}
catch (Exception ex)
{
Transaction?.Rollback();
var param = new
{
parametros = oracleParameterValues?.Where(s => s.Direction == ParameterDirection.Input).ToDictionary(l => l.ParameterName, l => l.Value),
procedure = storeProcedureName
};
ex.Data["parametros"] = JsonConvert.SerializeObject(param);
throw ex;
}
}
According to one site, they say it's a new feature of C # 8? it will be? Can you disable this? Because we use a refcursor.
-
Use:
.Net core 3.1
C# 8
Oracle.entityframeworkcore 2.19.60
I found that too. Has something to do with the new version? How to disable?
https://csharp.christiannagel.com/2018/06/20/nonnullablereferencetypes/
-
This tutorial looks like what you need to enable/disable nullable reference types:
https://docs.microsoft.com/en-us/dotnet/csharp/tutorials/nullable-reference-types
-
Alex,
Great reference friend. I did a basic test as the site mentioned and it worked perfectly, but when we use with object Datareader it keeps bringing the empty object. With dataredader is not working. See the example of the code we implemented. Do we need to do something or is this already suspected of a bug?
public async Task<DbDataReader> ExecutaCmdRetornoAsync(string sql)
{
var cmd = Con.CreateCommand();
cmd.CommandText = sql;
var reader = await cmd.ExecuteReaderAsync();
return reader;
}
public OracleDataReader ExecutaCmdRetorno(string sql)
{
var cmd = Con.CreateCommand();
cmd.CommandText = sql;
var reader = cmd.ExecuteReader();
return reader;
}