Search found 19 matches

by Settler
Mon 08 Aug 2011 10:26
Forum: dotConnect for PostgreSQL
Topic: Min Pool Size is not working.
Replies: 3
Views: 1428

Min Pool Size is not working.

When I try to set Min Pool Size connection string parameter the process is gone to infinite loop of creating and destroing connections.

My connection string is:

Code: Select all

User Id=postgres;Password=1;Host=localhost;Database=MyDb;Unicode=True;Persist Security Info=True;Schema=public;Min Pool Size=1;Max Pool Size=100;Connection Lifetime=1600;Pooling=True
From dbMonitor:

Code: Select all

Connect: User Id=postgres;Password=1;Host=localhost;Database=MyDb;Unicode=True;Persist Security Info=True;Schema=public;Min Pool Size=1;Max Pool Size=100;Connection Lifetime=1600;Pooling=True
Disconnect
Connect: ...
Disconnect
Connect: ...
Disconnect
dotConnect for PosgreSql 5.30.165.0
by Settler
Tue 31 May 2011 10:14
Forum: dotConnect for PostgreSQL
Topic: EntityFramework query with string.EndsWith throw exception
Replies: 4
Views: 1587

Thank you. We will wait.
by Settler
Thu 26 May 2011 12:12
Forum: dotConnect for PostgreSQL
Topic: EntityFramework query with string.EndsWith throw exception
Replies: 4
Views: 1587

EntityFramework query with string.EndsWith throw exception

I'm have simple query:

Code: Select all

using(var entities = new DataEntities())
{
    var test = entities.TestItems.Where(o=>o.Name.EndsWith("v")).ToList();
}
After runnings this code I catch this exception:
System.Data.EntityCommandCompilationException: An error occurred while preparing the command definition. See the inner exception for details.

System.NotSupportedException: The EDM function 'Edm.Reverse' is not supported.
at Devart.Common.Entity.ay.e(b7 A_0)
at Devart.Common.Entity.bd.a(b7 A_0)
at Devart.Common.Entity.b7.Accept[TResultType](EV`1 visitor)
at Devart.Common.Entity.bd.a(br A_0, br A_1, ck A_2)
at Devart.Common.Entity.bd.a(b7 A_0, br A_1, ck A_2)
at Devart.Common.Entity.bd.a(cl A_0)
at Devart.Common.Entity.cl.Accept[TResultType](EV`1 visitor)
at Devart.Common.Entity.bd.a(aq A_0, br A_1, Boolean A_2)
at Devart.Common.Entity.bd.a(bh A_0)
at Devart.Common.Entity.bh.Accept[TResultType](EV`1 visitor)
at Devart.Common.Entity.bd.a(br A_0, String A_1, TypeUsage A_2, q& A_3)
at Devart.Common.Entity.bd.a(ci A_0)
at Devart.Common.Entity.ci.Accept[TResultType](E...).
.....................

Methods "Contains" and "StartsWith" is work perfectly.

dotConnect for PostgreSql 5.30.160.
by Settler
Wed 18 Aug 2010 14:53
Forum: dotConnect for PostgreSQL
Topic: ArgumentException with ?: operator
Replies: 13
Views: 2106

Thnx for reply. I'm compare expression trees and found solution!
This query will execute as expected without any exceptions:

Code: Select all

long? condition = null; 
var query = from table in context.Table 
where condition == null ? true : table.Id == condition; 
I'm just remove call condition.Value that cause exception if condition value is null! This action force translator to wrap table.Id with Convert function for compare not nullable type with nullable type. And this will properly parsed by translator.

Thank you again ;)
by Settler
Tue 17 Aug 2010 12:58
Forum: dotConnect for PostgreSQL
Topic: ArgumentException with ?: operator
Replies: 13
Views: 2106

Oh. I see. But for me - this is not expected behavior. Why translator cannot translate "table.Id == condition.Value" to:
"public.Table."Id" is NULL"? - when condition == null
"public.Table."Id" = 1"? - when condition == 1?
Logically query public.Table."Id" is NULL is not correct, because column table.Id - is not nullable type, but for DataBase server this query is correct and return no results.

And when we see full example this will looks like:
LINQ:

Code: Select all

long? condition = null; 
var query = from table in context.Table 
where condition == null ? true : table.Id == condition.Value; 
Will be translated to:

Code: Select all

SELECT t1."Id" FROM public.Table t1
WHERE 
    (CASE 
        WHEN :p0 THEN :p1
        ELSE t1."Id" IS NULL
     END)
-------
p0 = true
p1 = true
And this LINQ:

Code: Select all

long? condition = 1; 
var query = from table in context.Table 
where condition == null ? true : table.Id == condition.Value; 
Will be translated to:

Code: Select all

SELECT t1."Id" FROM public.Table t1
WHERE 
    (CASE 
        WHEN :p0 THEN :p1
        ELSE t1."Id" = :p2
     END)
-------
p0 = false
p1 = true
p2 = 1
For simple understanding I can write this query:

Code: Select all

long? condition = null;
var query = from table in context.Table 
where table.Id == condition
select table;
And this query will execute as expected and no exceptions will throw. Why so limited behavior for ?: operator?
by Settler
Sun 15 Aug 2010 13:39
Forum: dotConnect for PostgreSQL
Topic: Completing a transaction with TransactionScope class
Replies: 9
Views: 6324

May be this is the same problem? Or solution will be the same?
http://www.devart.com/forums/viewtopic. ... ctionscope
by Settler
Thu 12 Aug 2010 14:15
Forum: dotConnect for PostgreSQL
Topic: new beta 4.90 issue
Replies: 7
Views: 1717

You are welcome. Keep working and make happy us - lazy programmers ;)
by Settler
Thu 12 Aug 2010 13:58
Forum: dotConnect for PostgreSQL
Topic: ArgumentException with ?: operator
Replies: 13
Views: 2106

Sorry for not full info. To reproduce issue you need to set condition variable to null. Like this:

Code: Select all

long? condition = null; 
var query = from table in context.Table 
where condition == null ? true : table.Id == condition.Value; 
And exception is not throw if I change code to this:

Code: Select all

long? condition = null; 
long conditionValue = condition == null ? -1 : conditionValue;
var query = from table in context.Table 
where condition == null ? true : table.Id == conditionValue; 
Exception is System.Reflection.TargetException with message Non-static method requires a target.

StackTrace:
в System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target)
в System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
в System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
в System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
в Devart.Data.Linq.Provider.Query.ak.b.a(Expression A_0)
в Devart.Data.Linq.v.a(BinaryExpression A_0)
в Devart.Data.Linq.v.b(Expression A_0)
в Devart.Data.Linq.v.a(ConditionalExpression A_0)
в Devart.Data.Linq.v.b(Expression A_0)
в Devart.Data.Linq.v.a(LambdaExpression A_0)
в Devart.Data.Linq.v.b(Expression A_0)
в Devart.Data.Linq.v.a(UnaryExpression A_0)
в Devart.Data.Linq.v.b(Expression A_0)
в Devart.Data.Linq.v.b(ReadOnlyCollection`1 A_0)
в Devart.Data.Linq.v.a(MethodCallExpression A_0)
в Devart.Data.Linq.v.b(Expression A_0)
в Devart.Data.Linq.v.b(ReadOnlyCollection`1 A_0)
в Devart.Data.Linq.v.a(MethodCallExpression A_0)
в Devart.Data.Linq.v.b(Expression A_0)
в Devart.Data.Linq.v.b(ReadOnlyCollection`1 A_0)
в Devart.Data.Linq.v.a(MethodCallExpression A_0)
в Devart.Data.Linq.v.b(Expression A_0)
в Devart.Data.Linq.Provider.Query.av.a(Expression A_0)
в Devart.Data.Linq.Provider.DataProvider.GetCompiledQueryFromCacheWithLock(Expression query, CompiledQueryCache& queryCache, a& hashKey)
в Devart.Data.Linq.Provider.DataProvider.BuildQuery(Expression query)
в Devart.Data.Linq.Provider.DataProvider.Devart.Data.Linq.Provider.IProvider.Compile(Expression query)
в Devart.Data.Linq.DataQuery`1.i()
в System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
в System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
в TestLinqCahing.Window1..ctor() в E:\Project\TestLinqCahing\TestLinqCahing\Window1.xaml.cs:строка 39
by Settler
Thu 12 Aug 2010 08:39
Forum: dotConnect for PostgreSQL
Topic: ArgumentException with ?: operator
Replies: 13
Views: 2106

One more issue with ?: operator.
Test code:

Code: Select all

long? condition = 1;
var query = from table in context.Table
where condition == null ? true : table.Id == condition.Value;
This code is also throw exception. If I rewrite it to this:

Code: Select all

long? condition = 1;
long conditionValue = condition.Value;
var query = from table in context.Table
where condition == null ? true : table.Id == conditionValue;
then all be alright.
by Settler
Wed 11 Aug 2010 15:34
Forum: dotConnect for PostgreSQL
Topic: new beta 4.90 issue
Replies: 7
Views: 1717

To reproduce issue you need to create generic function.
We use basic generic class to get data from database with dotConnect. All our entities is implement IIdEntity interface:

Code: Select all

    public interface IIdEntity
    {
        long Id { get; set; }
    }
So. in TestDataContext.cs create partial class for table ytrewqs:

Code: Select all

    partial class TestDataContext
    {

        // Place your implementation of partial extension methods here
    }

    public partial class ytrewqs: IIdEntity
    {

    }

    public interface IIdEntity
    {
        long Id { get; set; }
    }
And test code:

Code: Select all

        public void Test()
        {
                var except = new List();
                except.Add(1);
                var result1 = GetData(context, except );
                except.Add(2);
                var result2 = GetData(context, except );
        }

        private IList GetData(TestDataContext context, IEnumerable except)
            where T : class, IIdEntity
        {
            return context.GetTable().Where(o => !except.Contains(o.Id)).ToList();
        }
result1 and result2 will be the same.
by Settler
Wed 11 Aug 2010 15:03
Forum: dotConnect for PostgreSQL
Topic: ArgumentException with ?: operator
Replies: 13
Views: 2106

Thnx for reply. We will wait your fixes or any other results.
by Settler
Wed 11 Aug 2010 11:12
Forum: dotConnect for PostgreSQL
Topic: ArgumentException with ?: operator
Replies: 13
Views: 2106

And one more question.
dotConnect translate condition "tr.Status == (nullstatus ? null : new int?(-1))" to query with CASE operator. Can I rewrite this condition for avoid CASE operator in result query?

Simple example:

Code: Select all

bool condition = true;
var query = from table in context.Table
where condition == true ? table.Id == 1 : true
select table;
What I want to see in SQL query:
1) If "condition" == true, then "SELECT * FROM Table WHERE Table.Id = 1".
2) If "condition" == false, then "SELECT * FROM Table WHERE TRUE".

Can you give me some tricks or links to info?
by Settler
Tue 10 Aug 2010 09:22
Forum: dotConnect for PostgreSQL
Topic: new beta 4.90 issue
Replies: 7
Views: 1717

Build 4.95.152.

Same thing with caching queries that contains collections (for "IN" SQL operator). If I enable query caching and will execute one query many times with change collection, result will not change (I'm watch to dbMonitor and see, that SQL query (a part: "IN (x1, x2, x3, x4)") that become to PostgreSQL is not changes.

In smash example we use List collection.
by Settler
Tue 10 Aug 2010 08:26
Forum: dotConnect for PostgreSQL
Topic: ArgumentException with ?: operator
Replies: 13
Views: 2106

ArgumentException with ?: operator

We are start move our product from dotConnect for PostgreSQL 4.65 to 4.95.152. And this LINQ to SQL is worked in 4.65, but throw ArgumentException in 4.95.152:

Code: Select all

var query = from tr in context.Table
where tr.Status == (nullstatus ? null : new int?(-1)) || statuses.Contains(tr.Status) == statusesIn
select tr;
Variables nullstatus and statusesIn - is boolean variables. They are become true or false with some conditions. statuses - is a int?[] array.
Exception is throw when statuses is an empty array (not null, but int?[0]). If I remove first part of condition and rewrite LINQ like this:

Code: Select all

var query = from tr in context.Table 
where statuses.Contains(tr.Status) == statusesIn 
select tr;
the query will execute in any cases.

Please, look at this point and tell me if any fixes is available...
by Settler
Wed 16 Jun 2010 11:46
Forum: LinqConnect (LINQ to SQL support)
Topic: Bulk fetches with In operator. How to?
Replies: 1
Views: 1428

Bulk fetches with In operator. How to?

Hi.

I try to write this SQL query in LinqToSql:

Code: Select all

SELECT *
FROM directive_line t1
WHERE (t1."Id", t1."IdSomeOther") in ((13, 10), (11, 9))
I try this LinqToSql code:

Code: Select all

public class ObjectForQuery
{
    public long Id{get;set;}
    public long IdSomeOther{get;set;}
}

....

var objectsForSearch = new List
{
    new ObjectForQuery{Id = 13, IdSomeOther = 10},
    new ObjectForQuery{Id = 11, IdSomeOther = 9},
};

var list = (from directiveLineDB in context.DirectiveLines
where objectsForSearch.Select(o => new {o.Id, o.IdSomeOther }).Contains(new { Id = directiveLineDB .Id, IdSomeOther= directiveLineDB.IdSomeOther})
select directiveLineDB).ToList();
But i got System.InvalidOperationException:
"Could not format node 'New' for execution as SQL."

I'm do something wrong? How can I write this sql query in Linq?

dotConnect for PostgreSQL: 4.65.79.0