0

I have MySQL query

SELECT  Task_Number, BM_Number, BU, Status
FROM
    eng_effort 
    INNER JOIN eng_task on eng_effort.Eng_Task_ID = eng_task.Eng_Task_ID
where Status = "In Progress" and User_ID = "7"
group by Task_Number;

How do i write it in linq. please help.

2
  • What have you done so far? Do you already have done the connection to the db part or do you need help for this as well? Commented May 15, 2020 at 14:30
  • @OlivierJacot-Descombes : I have already done connection to be db using enity framework.. i want a that query to convert it in linq query. Commented May 15, 2020 at 14:32

1 Answer 1

1

Using the LINQ syntax, you can write something like this:

var query = (from effort in context.eng_effort
            join task in context.eng_task on effort.Eng_Task_ID equals task.Eng_Task_ID
            where task.Status == "In Progress" && task.User_ID == "7"
            select new { task.Task_Number, ... })
            .GroupBy(a => a.Task_Number);

Also, are you sure User_ID is a text column?

With the extension method syntax:

context.eng_effort
    .Join(
        context.eng_task,
        effort => effort.Eng_Task_ID,
        task => task.Eng_Task_ID,
        (effort, task) => (effort, task)) // Using a ValueTuple here
    .Where(et => et.task.Status == "In Progress" && et.task.User_ID == "7")
    .Select(et => new { et.task.Task_Number, ... })
    .GroupBy(a => a.Task_Number);   

Or you could perform a Perform grouped join.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, yes User_ID is string.. from above query i need group by eng_task. Task_Number

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.