Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 如何实现(简单?)linq查询_.net_Sql_Vb.net_Linq - Fatal编程技术网

.net 如何实现(简单?)linq查询

.net 如何实现(简单?)linq查询,.net,sql,vb.net,linq,.net,Sql,Vb.net,Linq,我要简化数据库。 下面是它的样子: 表: Main: Products: ID, Ref, Price, Translation: ID, Product_ID, Language_ID, Name Images: ID, Product_ID, Path, Index 我是linq的新手,我试着检索所有产品,它们的名称使用语言_ID=1,图像的索引为1 From p In db.Products Join t In db.Translate_Products On p.ID_Produc

我要简化数据库。
下面是它的样子:

表:

Main: Products: ID, Ref, Price, 
Translation: ID, Product_ID, Language_ID, Name
Images: ID, Product_ID, Path, Index
我是linq的新手,我试着检索所有产品,它们的名称使用语言_ID=1,图像的索引为1

From p In db.Products 
Join t In db.Translate_Products On p.ID_Product Equals t.Product_ID 
Join i In db.Images On p.ID_Product Equals i.Product_ID 
Where t.Language_ID = 1 And i.Index= 0 
Select p, t, i

你应该问“我如何接受答案”!十分之零令人印象深刻!13个问题,0个问题,你可能会考虑阅读STACKExchange WorkSokay.我承认我从来没有注意过!现在我知道这很重要了!事实上我不能让它工作。。。Visual studio不允许我在第二行有一个“进入”。。。请注意,请务必了解它的工作原理。在LINQ中,…into都无效。。验证p.ID_产品和t.Product_ID是否属于同一类型。。并分享您收到的错误消息..Visual studio说“指令结束例外”(在bleu中加下划线),这将是一些语法错误。。你需要检查一下。。但肯定不是关键词问题…Thanx但仍然不起作用。。。只需在db中从p写入。产品在db中加入t。将p.ID上的产品翻译为产品等于t.Product\U ID转换为结果1给我一个关于转换的错误。。。是vb吗?是C代码。。我使用相同的查询,但不同的表,它对我来说非常好。。我不知道你的案子伙计。。
From p In db.Products 
Join t In db.Translate_Products On p.ID_Product equals t.Product_ID into results1
from r1 in results.DefaultIfEmpty()
Join i In db.Images On p.ID_Product equals i.Product_ID 
into results2
from r2 in results2.DefaultIfEmpty()
Where results.Language_ID = 1 And i.Index= 0 
Select new
{

Productid = p.Productid,
..
..
..
}
From p In db.Products 
Join t In db.Translate_Products On p.ID_Product equals t.Product_ID 
into results1
from r1 in results1.DefaultIfEmpty()
Join i In db.Images On p.ID_Product equals i.Product_ID     
Where t.Language_ID == 1 And i.Index== 0 
Select new
{

Productid = p.Productid,
..
..
..
}