Page 1 of 1
Calling multiple functions in context
Posted: Tue 15 Sep 2009 14:22
by Trixz
I have a Oracle db and some storeprocedures and the call to these is executed as select package.myFunction(param) from dual.
Since i sometimes call lots of functions in the code i would find it useful to be able to call function at the same time.
var param = (from d in contex.dual
select new { result1 = context.myFunction(param), result2 = context.myFunction2() });
This way I don't need to make the same amount of database call in a time critical area.
I'm guessing this can be achieved in some way, but dual does not exist in context...
Posted: Wed 16 Sep 2009 14:11
by AndreyR
Try the following code:
Code: Select all
var param = new { result1 = context.myFunction(param), result2 = context.myFunction2() };
Posted: Fri 18 Sep 2009 08:42
by Trixz
Thanks for the suggestion, but it does not work.
The code i valid and I get a result in both params but when I look at the output from Context.log I see that it makes 2 seperate calls to the database.
Posted: Fri 18 Sep 2009 10:31
by AndreyR
Try this code, it worked for me.
Code: Select all
var q = from d in db.Query("dual")
select new
{
result1 = db.GetTest1(0),
result2 = db.GetTest2(0)
};
Posted: Fri 18 Sep 2009 10:48
by Trixz
Don't work for me.
In the output i get this
Code: Select all
dual
SELECT jfp.jfp_order.get_order_value1(:p0) AS C1 FROM DUAL
ParameterName = p0
DbType = Decimal
Value = 1021
SELECT jfp.jfp_order.get_order_value2(:p0) AS C1 FROM DUAL
ParameterName = p0
DbType = Decimal
Value = 1021
A first chance exception of type 'Devart.Data.Oracle.OracleException' occurred in Devart.Data.dll
This is my code (Linq to Sql did not have any context.Query so I guessed that that equals ExecuteQuery
Code: Select all
var p = (from d in context.ExecuteQuery("dual")
select new
{
result1 = context.GetFirst(param1),
result2= context.GetSecond(param2)
}).First();
[/code]
Posted: Fri 18 Sep 2009 11:12
by AndreyR
It isn't the same method. The Query method was added in the 5.25.42 version of dotConnect for Oracle.
The ExecuteQuery method returns IEnumerable instance, and the Query method returns IQueryable instance.