Calling multiple functions in context

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
Trixz
Posts: 31
Joined: Thu 30 Apr 2009 07:59

Calling multiple functions in context

Post by Trixz » Tue 15 Sep 2009 14:22

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...

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Wed 16 Sep 2009 14:11

Try the following code:

Code: Select all

var param = new { result1 = context.myFunction(param), result2 = context.myFunction2() };

Trixz
Posts: 31
Joined: Thu 30 Apr 2009 07:59

Post by Trixz » Fri 18 Sep 2009 08:42

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.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Fri 18 Sep 2009 10:31

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)
                };

Trixz
Posts: 31
Joined: Thu 30 Apr 2009 07:59

Post by Trixz » Fri 18 Sep 2009 10:48

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]

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Fri 18 Sep 2009 11:12

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.

Post Reply