Connecting to Oracle using ODP.NET
I was told in the comments that it is off-topic, and someone has also downvoted it without any explanation.
I have shown code that works fine and want it reviewed. Please give your feedback.
Connecting to Oracle using ODP.NET
I was told in the comments that it is off-topic, and someone has also downvoted it without any explanation.
I have shown code that works fine and want it reviewed. Please give your feedback.
Entity Framework has a provider for Oracle.
That would be an alternative, and it would answer your question.
Would it be a good CR answer? Certainly not. The way I read your question, it's like asking "How can I write this query in a strongly-typed manner, without those magic strings?", which is essentially asking for code to be written.
A Code Review answer would be more like this:
You're using
using
blocks to dispose your disposables, which is excellent. However these blocks increase the nesting of your code; since there's nothing betweenusing (var oracleConnection = new OracleConnection(ConnectionString))
andusing (var oracleCommand = oracleConnection.CreateCommand())
you could drop the curly braces and write it like this:using (var oracleConnection = new OracleConnection(ConnectionString)) using (var oracleCommand = oracleConnection.CreateCommand()) { ... }
Within that scope, you're reassigning variable
Id
at each row that gets read; ultimately the value ofId
will be that of the last row that was read. I doubt this is the intended behavior.
The three current votes on your question are not suggesting it's off-topic, they are all 'It's unclear what you are asking'.
Your title and the actual question you have are a little bit contradictory too:
Title:
C# with Oracle ODP.NET. CommandText alternatives
Actual question you ask:
Is there any alternatives to write oracleCommand.CommandText as a text?
If the title of your question was: Are there any alternatives .... ?
then this would certainly be off-topic for CodeReview. As it stands at the moment, it is just unclear.
The title suggests you are using some form of alternatives, but your code contradicts that.