我想把这个SQL转换成LINQ,但是遇到了困难,有没有人能帮我?非常感谢,以下是SQL代码:
select publication_id, publication_code, publication_name
from tbl_PUBLICATION
where AIG_PUB = 1
order by PUBLICATION_NAME
顺便说一下,AIG_PUB字段是位类型,
发布于 2018-06-09 03:46:45
tbl_PUBLICATION
.Where(p => p.AIG_PUB)
.OrderBy(p => p.PUBLICATION_NAME);
或者如果您坚持只选择这些列
tbl_PUBLICATION
.Where(p => p.AIG_PUB == true)
.OrderBy(p => p.PUBLICATION_NAME)
.Select(p => new {
publication_id = p.publication_id,
publication_code = p.publication_code,
publication_name = p.publication_name
});
发布于 2018-06-09 03:55:42
这也许可以解决这个问题。
var MyResults = tbl1_PUBLICATION
.Where( x => x.AIG_PUB == 1)
.Select( p => new {
publication_id = p.publication_id,
publication_code = p.publication_code,
publication_name = p.publication_name})
.OrderBy( p => p.PublicationName);
我还没有测试过,所以如果你看到任何打字错误,请让我知道,
https://stackoverflow.com/questions/50765358
复制相似问题