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.

| |
  • 1
    \$\begingroup\$ Thank you for addressing your concern here. I have temporarily locked your question so that further discussion can be directed here. Once a consensus is reached, please flag for unlocking. \$\endgroup\$ – Jamal Dec 5 '13 at 13:18
  • \$\begingroup\$ @Jamal I have edited my queustion. Take a look at it please. Ant it can be unlocked \$\endgroup\$ – MikroDel Dec 5 '13 at 16:30
  • \$\begingroup\$ It looks better now. The lock was only for an hour, hence why you were still able to edit (locks prevent all activity from non-moderators except for flagging and favoriting). Again, thank you for posting here. I'll clean up the comment section now. \$\endgroup\$ – Jamal Dec 5 '13 at 16:34

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 between using (var oracleConnection = new OracleConnection(ConnectionString)) and using (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 of Id will be that of the last row that was read. I doubt this is the intended behavior.

| |
  • \$\begingroup\$ I have edited my question. Thanks for repsonse. Upvote + accept. \$\endgroup\$ – MikroDel Dec 5 '13 at 16:31
  • \$\begingroup\$ @MikroDel removed downvote on your original post :) \$\endgroup\$ – Mathieu Guindon Dec 5 '13 at 16:57
  • 1
    \$\begingroup\$ @MikroDel actually, upvoted and answered! \$\endgroup\$ – Mathieu Guindon Dec 5 '13 at 17:06

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:


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.

| |
  • \$\begingroup\$ I have edited my question. Thanks for repsonse. Upvote. \$\endgroup\$ – MikroDel Dec 5 '13 at 16:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .