将复合连接linq写入sql语句的最佳方法 [英] Best way to write a compound join linq to sql statement

查看:69
本文介绍了将复合连接linq写入sql语句的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试使用linq-to-sql编写复合连接语句.我遇到了一些似乎无法克服的编译时问题.有人可以向我介绍一下编写linq-to-sql join语句的最佳方法是什么吗?

这是我到目前为止的内容:

Hi everyone,

I am trying to write a compound join statement using linq-to-sql. I am running into some compile time issues that I can''t seem to overcome. Can someone shed some light for me as to what is the best way to proceed with writing linq-to-sql join statements?

Here is what I have so far:

var acc_ped_pos =
                from v in vehicles
                from e in engine
                where v.engine_type == e.engine_type && v.engine_code == e.engine_code
                select e.accelerator_pedal_position;


编译器说名称或类型名称空间名称"SelectMany"在名称空间车辆"中不存在(您是否缺少程序集引用)?
名称引擎在当前上下文中不存在.

我的数据库设置有表名引擎和车辆.

预先感谢您的帮助!


The compiler says "The type or namespace name "SelectMany" does not exist in the namespace "vehicles" (are you missing an assembly reference)?
The name engine does not exist in the current context.

I have my database set up with a table name engine and vehicles.

Thanks in advance for any assistance!

推荐答案

我认为,您需要使用 ^ ]命令;)
I think, you need to use join[^] command ;)
var acc_ped_pos = from v in vehicles join e in engine
                where v.engine_type == e.engine_type && v.engine_code == e.engine_code
                select e.accelerator_pedal_position;



在这里看看:在C#中使用简单LINQ to SQL [ ^ ]



Have a look here to: Simple LINQ to SQL in C#[^]


这篇关于将复合连接linq写入sql语句的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆