new beta 4.90 issue

new beta 4.90 issue

Postby smash » Wed 03 Mar 2010 18:58

So.
how to reproduce issue:

create table ytrewqs

id|Name
1 |One
2 |Two
3 |Three

using version 4.65 and it's standard c# templates create model from database with this table
write, compile and run this

Code: Select all
            var context = new TestDataContext();
            var notin = new List {1};
            var entities = context.ytrewqs.Where(o=> !notin.Contains(o.id));
            Console.WriteLine(entities.Count());//result 2
            notin.Add(2);
            Console.WriteLine(entities.Count());//result 1


after that uninstall 4.65 and install 4.90
check referencies and without code regeneration run code. result is as expected;

then recreate model from database and again run this code. entities.Count() in both lines returns 2.

if rewrite code like this

Code: Select all
            var context = new TestDataContext();
            var notin = new List {1};
            var entities = context.ytrewqs.Where(o=> !notin.Contains(o.id));
            Console.WriteLine(entities.Count());//result 2
            var notin = new List {1,2};
            var entities = context.ytrewqs.Where(o=> !notin.Contains(o.id));
            Console.WriteLine(entities.Count());//result 1


result will be as expected. please check this. same thing with 4.75


BTW. The templates from 4.65 incompatible to 4.90
smash
 
Posts: 1
Joined: Wed 03 Mar 2010 18:22

Postby AndreyR » Fri 05 Mar 2010 12:23

Thank you for the report, we will analyze this behaviour.
I will let you know about the results of our investigation.
As a temporary workaround, just comment out this line in the template:
Code: Select all
public static Devart.Data.Linq.CompiledQueryCache compiledQueryCache = Devart.Data.Linq.CompiledQueryCache.RegisterDataContext(typeof(<#= contextClassName #>));

This will turn off query caching.
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Postby AndreyR » Fri 23 Jul 2010 17:57

This problem is fixed in the current build.
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Postby Settler » Tue 10 Aug 2010 09:22

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.
Settler
 
Posts: 19
Joined: Mon 01 Mar 2010 16:32

Postby StanislavK » Wed 11 Aug 2010 14:47

Could you please specify the exact query (and table) with which the problem can be reproduced? We couldn't reproduce it with simple queries like in the following sample:
Code: Select all
var context = new TestDataContext();
var inArray = new List { 1 };
var entities =
  from item in context.ytrewqs where inArray.Contains(item.id) select item;
Console.WriteLine(entities.Count()); // Prints 2
inArray.Add(2);
Console.WriteLine(entities.Count()); // Prints 1

(the 'ytrewqs' table is the one from the smash's example).
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Postby Settler » Wed 11 Aug 2010 15:34

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.
Settler
 
Posts: 19
Joined: Mon 01 Mar 2010 16:32

Postby StanislavK » Thu 12 Aug 2010 12:43

Thank you for your assistance, we've reproduced the problem with the generic class. We will investigate it and inform you about the results.
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Postby Settler » Thu 12 Aug 2010 14:15

You are welcome. Keep working and make happy us - lazy programmers ;)
Settler
 
Posts: 19
Joined: Mon 01 Mar 2010 16:32


Return to dotConnect for PostgreSQL