Linq to sql查询实现 [英] Linq to sql query implementation

查看:68
本文介绍了Linq to sql查询实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想写一个linq到sql查询.我要实现的查询是:

Hello all,

I want to write a linq to sql query. the query that I want to implement is:

SELECT lbl.STATUS, lbl.TYPE 
FROM LABELS as lbl
JOIN RECORDS as rec ON lbl.ID = rec.LABELID
WHERE rec.STATUS == 0 OR rec.STATUS == 1 or rec.STATUS == 2



我已经尝试过



I have tried

var trackingQuery = from t in dbContext.LABELS
                    from r in dbContext.RECORDS.Where(a => a.recStatus.Value = 0 || a.recStatus.Value = 1 || a.recStatus.Value = 2)
                    select new
                    {
                      t.STATUS,
                      t.TYPE
                    }



我遇到运算符|||"无法应用于类型为"int"和"int""的操作数,但此错误无法解决.有人可以帮我吗?谢谢



I am having "Operator ''||'' cannot be applied to operands of type ''int'' and ''int''" this error but couldnt resolve this. Can someone help me out? Thanks

推荐答案

尝试a.rmaStatus.值 = 0 ...
Try a.rmaStatus.Value = 0...


您需要使用==代替=

例如

You need to use == instead of =

e.g

var trackingQuery = from t in dbContext.LABELS
                    from r in dbContext.RECORDS.Where(a => a.recStatus.Value == 0 || a.recStatus.Value == 1 || a.recStatus.Value == 2)
                    select new
                    {
                      t.STATUS,
                      t.TYPE
                    }


这篇关于Linq to sql查询实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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