Linq: Problem with Multi-column primary key. MultiKeyManager

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
Andrew
Posts: 9
Joined: Thu 28 Aug 2008 20:24

Linq: Problem with Multi-column primary key. MultiKeyManager

Post by Andrew » Tue 16 Sep 2008 22:26

Hello.

I have a problem that I believe stems from the use of two columns as the primary key. Whenever I try to query the table with linq; i get this error:

Code: Select all

[InvalidOperationException: Sequence contains no matching element]
   System.Linq.Enumerable.Single(IEnumerable`1 source, Func`2 predicate) +320
   Devart.Data.Linq.MultiKeyManager`2.a() +309
   Devart.Data.Linq.MultiKeyManager`2.a(Type A_0) +491
   Devart.Data.Linq.MultiKeyManager`2.a(Type A_0) +230
   Devart.Data.Linq.MultiKeyManager`2.CreateDefault() +264
   Devart.Data.Linq.MultiKeyManager`2.a(T A_0) +125
   Devart.Data.Linq.Provider.EntityReader`2.a() +70
   Devart.Data.Linq.Provider.ObjectReader`1.MoveNext() +22
   FindLocationLib.XioneticClasses.DBUtil.GetXioneticUserByUserId(String userId) in C:\Develop\FindLocationDevelop\FindLocationLib\XioneticClasses\DBUtil.cs:24
   FindLocation.Login.Login1_LoggedIn(Object sender, EventArgs e) in C:\Develop\FindLocationDevelop\FindLocation\Login.aspx.cs:34
   System.Web.UI.WebControls.Login.OnLoggedIn(EventArgs e) +105
   System.Web.UI.WebControls.Login.AttemptLogin() +205
   System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +99
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
   System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +115
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +163
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746


And here is the SQL Create statement for my table:

Code: Select all

DROP TABLE IF EXISTS `findlocation`.`fluser`;
CREATE TABLE  `findlocation`.`fluser` (
  `user_id` varchar(45) NOT NULL,
  `client_id` int(10) unsigned NOT NULL,
  `parent_id` varchar(45) default NULL,
  PRIMARY KEY  (`user_id`,`client_id`),
  KEY `FK_fluser_1` (`client_id`),
  CONSTRAINT `FK_fluser_1` FOREIGN KEY (`client_id`) REFERENCES `client` (`client_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Any ideas?

Thanks!
AFrieze

P.s. Really enjoying linq!

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Fri 19 Sep 2008 12:28

We cannot reproduce the problem. Please provide us (alexsh at devart.com) with the test project, where the error arises, and the full script. The one you have posted here doesn't contain a definition for the table 'client' that you create constraint for.

Andrew
Posts: 9
Joined: Thu 28 Aug 2008 20:24

Post by Andrew » Fri 19 Sep 2008 20:23

Shalex
Sorry about forgetting the client table. Here it is.

Code: Select all


DROP TABLE IF EXISTS `findlocation`.`client`;
CREATE TABLE  `findlocation`.`client` (
  `client_id` int(10) unsigned NOT NULL auto_increment,
  `client_name` varchar(45) NOT NULL,
  `xionetic_id` int(10) unsigned NOT NULL,
  PRIMARY KEY  (`client_id`)
) ENGINE=InnoDB AUTO_INCREMENT=956 DEFAULT CHARSET=latin1;
The project no longer has this error as I have programmed around it with a one column primary key. I can try to replicate it again if it would be helpful to you.

Thanks!
Andrew

Post Reply