问题 - 使用Windows窗体ComboBox进行Linq to SQL查询 [英] Problem - Linq to SQL Query with Windows Forms ComboBox

查看:39
本文介绍了问题 - 使用Windows窗体ComboBox进行Linq to SQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我有一个问题,我似乎无法找到解决方案。

我有这段代码可以工作:


Hello,

I have a problem which I cannot seem to find a solution to.

I have this piece of code which works:





















PhoenixDataContext dc = new PhoenixDataContext();
var searchQType =(来自dc.GetTable中的q < 问题 > ()
其中 q.Question_Type.QuestionType ==" True或False"
选择q);
var display = searchQType 。ToList();
dataGridView1.DataSource = display ;
            PhoenixDataContext dc = new PhoenixDataContext();  
 
            var searchQType = (from q in dc.GetTable<Question>()  
                               where q.Question_Type.QuestionType == "True or False"  
                               select q);  
 
            var display = searchQType.ToList();  
            dataGridView1.DataSource = display

推荐答案

尝试添加拦截正在发布的SQL到数据库看看是否能提供任何有关为什么失败的见解。您可以使用Console.Writeline(searchQType.ToString())执行此操作;或者将日志添加到数据上下文,如下所示:

dc.Log = Console.Out;

然后,您将在输出窗口中看到生成的SQL语句(假设您使用的是Winform)解决方案。

Jim Wooley
www.ThinqLinq.com
Try adding an intercepting the SQL that is being issued to the database to see if that offers any insights into why this is failing for you. You can either do this with using Console.Writeline(searchQType.ToString()); or add a log to the data context as follows:

dc.Log = Console.Out;

You will then see the resulting SQL statements in the output window (assuming you are using a Winform solution.

Jim Wooley
www.ThinqLinq.com


这篇关于问题 - 使用Windows窗体ComboBox进行Linq to SQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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