Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modify "model" to add relationships in LinqPad?

Tags:

c#

linq

linqpad

I'm using LinqPad to query a MySQL MyISAM database. There are foreign keys, but no constraints on them, so LinqPad can't pick up the relationship. I'd like to add these relationships (tell it which fields are FKs) to make querying easier. Is this possible?

like image 456
mpen Avatar asked Nov 04 '22 11:11

mpen


2 Answers

There's no way to do this other than adding the foreign key constraints. (As a matter of interest, what's the reason for not having foreign key constraints?)

like image 95
Joe Albahari Avatar answered Nov 15 '22 13:11

Joe Albahari


If there aren't FKs set up, then you only have one option.

You must join your tables manually using LINQ.

If you really want to use dot-notation, I think you can change your statement type to "C# Program" and put the LINQ in an extension method.

like image 24
Scott Rippey Avatar answered Nov 15 '22 12:11

Scott Rippey