- Back to Home »
- WCF Solution
1) Create WCF Service Application
2) Add DataLayer (Entity Framework)
3) Add this to IStudentService -
[ServiceContract]
public interface IStudentService
{
[OperationContract]
void DoWork();
[OperationContract]
int SaveStudent(Student student);
}
4) Implement the Service in SrudentService.svc -
public class StudentService : IStudentService
{
// public StudentModelEntities;
public void DoWork()
{
}
public int SaveStudent(Student student)
{
try
{
using (var db = new SINGADBEntities())
{
db.Students.Add(student);
db.SaveChanges();
}
return student.Id;
}
catch (Exception)
{ return 0; }
}
}
5) Add app.config connectionString of DataLayer to the web.config of WCF Servie Project.