开发者

How can i convert my Sql codes to Linq?

i try to convert my SQL code to linq but i cannot:


Alter PROCEDURE sp_MatchCTallyToTask
AS
BEGIN

 select * from Task where MPDReference in(  select MPDReference from Task 
intersect
select ENG_CUSTOMERTALLY_CUSTOMERTASKNUMBER from dbo.ENG_CUSTOMERTALLY)
END
GO


 public List<Task> TaskList()
        {
            return engCtx.Tasks.Where(t => t.MPDReference.Contains(engCtx.ENG_CUSTOMERTALLies.Select(c => c.ENG_CUSTOMERTALLY_CUSTOMERTASKNUMBER).
                Except(engCtx.Tasks.Se开发者_运维问答lect(tsk => tsk.MPDReference).AsQueryable())).ToList());

        }


You can import the stored procedure into your LINQ model, and then simply call the stored procedure.

You will have the benefits of LINQ, without rewriting everyting.


You don't need to do it like that. Corresponding code in sql would look like this:

select * from Task t
join dbo.ENG_CUSTOMERTALLY ect on ect.ENG_CUSTOMERTALLY_CUSTOMERTASKNUMBER = t.MPDReference 

So you need to join those busters in your linq query.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜