Click here to Skip to main content
15,897,182 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I try to create LINQ update query
i try this sp

SQL
ALTER procedure [dbo].[updateselect_Data]
@ServiceID int,
@Service_frequency nvarchar(50),
@Next_Service nvarchar(50),
@Create_reminder nvarchar(50)

as
Update tbl_fl_Services_schedule
SET 
tbl_fl_Services.Service_frequency=@Service_frequency,
tbl_fl_Services.Next_Service=@Next_Service,
tbl_fl_Services.Create_reminder=@Create_reminder
where
ServiceID=@ServiceID


What I have tried:

query
C#
public static string updateselect_data(int ServiceID, string Service_frequency, string Next_Service, string Create_reminder)
        {
            Data track = new Data();

            var update = (from p in track.tbl_fl_Services where p.ServiceID == ServiceID select p).ToList()
                .ForEach(x => x.Service_frequency = Service_frequency);
}


now i select multiple value in for each loop ?
Posted
Updated 12-Oct-16 23:37pm
Comments
Suvendu Shekhar Giri 13-Oct-16 3:56am    
What's is the issue here?
Can you please explain?
super_user 13-Oct-16 7:43am    
how to call parameters Service_frequency ,Next_Service,Create_reminder in foreach loop

1 solution

Create a function that copies the values onto the object and call that function from your ForEach

C#
// I've guessed the type of your schedule object, you'll need to supply the correct type
public void Update(tbl_fl_Services_schedule schedule, string Service_frequency, string Next_Service, string Create_reminder)
{
    schedule.Service_frequency = Service_frequency;
    schedule.Next_Service = Next_Service;
    schedule.Create_reminder = Create_reminder;
}


C#
.ForEach(x => Update(x, Service_frequency, Next_Service, Create_reminder));
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900