Click here to Skip to main content
12,699,883 members (36,149 online)
Rate this:
Please Sign up or sign in to vote.
See more: WCF LINQ
hi all,

i have a sql table(emp_id,ename,e_sal).now i want to inserting some rows through the client application.
here i need to create a wcf service to inserting the data into sqldatabase through the LINQ for that how can create a wcf service to inserting the data into sqlDB.

note: this service has three inserting parameters are(emp_id,ename,e_sal).

please any body help to me.
thanks in advance.......

thanks and regards,
Posted 21-May-12 21:46pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

you can make this:

public class Employee
  public int Id;

  public string Name;

  public decimal Salary;

public interface IService
  void AddEmployee(Employee employee);

Implement method AddEmployee in server and just call it from client. Client should now nothing about SQL, otherwise its no point to make WCF.

As for insert phase implementation it has nothing to do with WCF. Refer to LinqToSQL using-linq-to-sql-part-1 or Simple-LINQ-to-SQL-in-C

If you have DataContext then you can do following:
// connect
MyDataCotext db = new MyDataCotext();

// generate new record
EmployeeRecord/*(this is what comes from DBContext)  */ emp = new EmployeeRecord();

// assign values
emp.Id = Employee.Id
emp.Name = Employee.Name
emp.Salary = Employee.Salary

// add to database
Unareshraju 22-May-12 3:15am
hi shawnas thanks to u r reply,
i was connected to database through the LINQ for that no need to declare data contract,
i am inserting the values through the my application(wpf in that text boxes) .please any help how write insert command when i am inserting values through the my application

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170118.1 | Last Updated 22 May 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100