Page 1 of 1

why i got same result

Posted: Mon 26 Sep 2011 16:49
by mmp7uk
use ver3 / mysql 5.5.12 / Win7 x64 / C#

I found I always got same result

my test code is.

Code: Select all

            

Abc.myDataContext con = new Abc.myDataContext(); 
con.Log = Console.Out;

var a = con.Monos.SingleOrDefault(x => x.UrlHash == "3D6B6976172C656F3EE3EF45B1442776");
Console.WriteLine(a.Title);

var b = con.Monos.SingleOrDefault(x => x.UrlHash =="314198768635805D5F979D0B57B5881C");
Console.WriteLine(b.Title);

Console.ReadLine();
but I got this:

Code: Select all

SELECT t1.Id, t1.Url, t1.CategoryId, t1.Title, t1.Description, t1.Tosion, t1.Cre
atedAt, t1.ModifiedAt, t1.UrlHash, t1.GoodMember, t1.BadMember, t1.Favicon, t1.D
omain, t1.GoodPoint, t1.BadPoint, t1.UrlType, t1.Tags, t1.Thumbnail, t1.Summary,
 t1.ShortenUrl, t1.Views, t1.R18
FROM abida.mono t1
WHERE t1.UrlHash = :p0
-- p0: Input VarChar (Size = 32; DbType = AnsiString) [3D6B6976172C656F3EE3EF45B
1442776]
-- Context: Devart.Data.MySql.Linq.Provider.MySqlDataProvider Model: an Build: 3
.0.4.0

This is title A
SELECT t1.Id, t1.Url, t1.CategoryId, t1.Title, t1.Description, t1.Tosion, t1.Cre
atedAt, t1.ModifiedAt, t1.UrlHash, t1.GoodMember, t1.BadMember, t1.Favicon, t1.D
omain, t1.GoodPoint, t1.BadPoint, t1.UrlType, t1.Tags, t1.Thumbnail, t1.Summary,
 t1.ShortenUrl, t1.Views, t1.R18
FROM abida.mono t1
WHERE t1.UrlHash = :p0
-- p0: Input VarChar (Size = 32; DbType = AnsiString) [3D6B6976172C656F3EE3EF45B
1442776]
-- Context: Devart.Data.MySql.Linq.Provider.MySqlDataProvider Model: an Build: 3
.0.4.0

This is title A
I mean i passed 2 different ids:

3D6B6976172C656F3EE3EF45B1442776
and
314198768635805D5F979D0B57B5881C

but the linqConnect generated two same query with first id "3D6B6976172C656F3EE3EF45B1442776" twice, so i got same results, why?

the id is Unique column in the table.

more sample

Posted: Tue 27 Sep 2011 02:57
by mmp7uk
I test again.

this is my test table

Code: Select all

CREATE TABLE `testtable` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Name` varchar(45) NOT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Id_UNIQUE` (`Id`)
) ENGINE=InnoDB
this is my linq syntax:

Code: Select all

            TestContext.TestDataContext con = new TestContext.TestDataContext();
            con.Log = Console.Out;

            var a = con.Testtables.FirstOrDefault(x => x.Name == "Name-A");
            var b = con.Testtables.FirstOrDefault(x => x.Name == "Name-B");
            var c = con.Testtables.FirstOrDefault(x => x.Name == "News");
            var d = con.Testtables.FirstOrDefault(x => x.Name == "XYZ");
and i got this results:

Code: Select all

SELECT t1.Id, t1.Name
FROM test.testtable t1
WHERE t1.Name = :p0 LIMIT 1
-- p0: Input VarChar (Size = 6; DbType = AnsiString) [Name-A]
-- Context: Devart.Data.MySql.Linq.Provider.MySqlDataProvider Model: an Build: 3
.0.4.0

SELECT t1.Id, t1.Name
FROM test.testtable t1
WHERE t1.Name = :p0 LIMIT 1
-- p0: Input VarChar (Size = 6; DbType = AnsiString) [Name-A]
-- Context: Devart.Data.MySql.Linq.Provider.MySqlDataProvider Model: an Build: 3
.0.4.0

SELECT t1.Id, t1.Name
FROM test.testtable t1
WHERE t1.Name = :p0 LIMIT 1
-- p0: Input VarChar (Size = 6; DbType = AnsiString) [Name-A]
-- Context: Devart.Data.MySql.Linq.Provider.MySqlDataProvider Model: an Build: 3
.0.4.0

SELECT t1.Id, t1.Name
FROM test.testtable t1
WHERE t1.Name = :p0 LIMIT 1
-- p0: Input VarChar (Size = 3; DbType = AnsiString) [XYZ]
-- Context: Devart.Data.MySql.Linq.Provider.MySqlDataProvider Model: an Build: 3
.0.4.0
so why I got same [Name-A] 3 times and one [XYZ] query?

Posted: Tue 27 Sep 2011 06:08
by Zero-G.
Hey
I am not a devart guy, but maybe, I have a workaround for you.
In the generated template, of the datacontext, you can find a definition of precompiled query.
It should look like this (it is translated from the VB version)

Code: Select all

public static Devart.Data.Linq.CompiledQueryCache compiledQueryCache = Devart.Data.Linq.CompiledQueryCache.RegisterDataContext(typeof(DataContext));

uncomment this line and try again. - There have been a few problems with the precompiled queries in the past, but your problem was solved long time ago, when you are really using v3.

Thanks

Posted: Wed 28 Sep 2011 09:51
by mmp7uk
Thanks! Zero-G.

The problem solved after I uncomment the line.

but I am really using v3

Image

Zero-G. wrote:Hey
I am not a devart guy, but maybe, I have a workaround for you.
In the generated template, of the datacontext, you can find a definition of precompiled query.
It should look like this (it is translated from the VB version)

Code: Select all

public static Devart.Data.Linq.CompiledQueryCache compiledQueryCache = Devart.Data.Linq.CompiledQueryCache.RegisterDataContext(typeof(DataContext));

uncomment this line and try again. - There have been a few problems with the precompiled queries in the past, but your problem was solved long time ago, when you are really using v3.

Posted: Wed 28 Sep 2011 13:47
by StanislavK
The problem is that the compiled query cache stores the query with the parameters, and the 3.0.4 version has a bug related to distinguishing two queries, whose only difference is in the value of a parameter. This bug is already fixed, the fix will be available in the nearest build which we plan to release in several days.