Posted by : sinhalamp3 Saturday, June 4, 2016

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.
 
   

 

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Popular Post

Blogger templates

lakshika345@gmail.com. Powered by Blogger.

- Copyright © mp3s for you -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -