On Apr 26, 12:05 pm, Pietro <[email protected]> wrote:
> i've found a bug on the last release of DBLinq when i try to update an
> entity using Oracle and ODP.NET.
>
> ODP.NET have a problem with OracleCommand and its parameters, the
> command don't find parameters by ID but only by Name, so when we try
> to update a field on a table and dblinq generate the sql command with
> the parameters the ExecuteNonQuery don't through and don't update
> nothing.

Thanks for reporting this. To make sure, we are talking about the same
thing: Does this test case illustrate the problem or do you have
another test case?

using (var context = new ReadTest().CreateDB()) {
  var c = context.Categories.First();
  c.CategoryName += "!";
  context.SubmitChanges();
}

When run from Program3Ora.cs in DbLinq.Oracle_test_odp, it attempts to
execute two queries, but fails during the second with the error
"ORA-01722: invalid number" (probably because "Beverages!" isn't a
number):

SELECT LimitedTable___.*, rownum Limit___ FROM (
SELECT "CategoryID", "CategoryName", "Description", "Picture"
FROM "NORTHWIND"."Categories"
) LimitedTable___ WHERE rownum <= 1

UPDATE "NORTHWIND"."Categories" SET "CategoryName" = :CategoryName
WHERE "CategoryID" = :CategoryID
-- :CategoryID: Input Decimal (Size = 0; Prec = 0; Scale = 0) [1]
-- :CategoryName: Input String (Size = 0; Prec = 0; Scale = 0)
[Beverages!]

Adding your change (simplified a bit) seem to solve the problem:

Index: DatabaseContext.cs
===================================================================
--- DatabaseContext.cs  (revision 1408)
+++ DatabaseContext.cs  (working copy)
@@ -117,6 +117,12 @@
         public IDbCommand CreateCommand()
         {
             IDbCommand command = Connection.CreateCommand();
+            if (command.GetType().FullName ==
"Oracle.DataAccess.Client.OracleCommand")
+            {
+                var p = command.GetType().GetProperty("BindByName");
+                if (p != null)
+                    p.SetValue(command, true, null);
+            }
             if (command.Transaction == null)
                 command.Transaction = CurrentTransaction;
             return command;

--
Anders

-- 
You received this message because you are subscribed to the Google Groups 
"DbLinq" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/dblinq?hl=en.

Reply via email to