Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hi i am new to .net and i got internship in company and they told me to work on wcf data service without any training. i learned the wcf data service through the entity framework but they require the application needs to work without entity framework so any one know how to implement the wcf data service without entity framework actually i done some coding i don't how to call that method to intialse the service so please any one help me
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace Wcfdataserviceconsole
{
   public class Employee
    {
        public int id { get; set; }
        public string name { get; set; }
     
       public Employee()
        {
        }
    }
        public class EmployeeDetails
        {
            public string ConnectionString = "Data Source=(local);Initial Catalog=Employee;Integrated Security=True";
            public SqlConnection Con =null;
           
            public List<Employee> Implementation()
            {
                  
                List<Employee> employee= new List<Employee>();
                Con = new SqlConnection(ConnectionString);
                Con.Open();
                string str = "select * from Employee";
                SqlCommand Cmd = new SqlCommand(str, Con);
                SqlDataReader sqlDataReader = Cmd.ExecuteReader();
                while (sqlDataReader.Read())
                {
                    Employee emp = new Employee();
                    emp.id = sqlDataReader.GetInt32(0);
                    emp.name = sqlDataReader.GetString(1);
                    employee.Add(emp);
                }
                return employee;
            }
            public IQueryable<Employee> EmployeeContext
            {
                get
                {
                    return new EmployeeDetails().Implementation().AsQueryable();
                }
            }
        }
    }

i done this code iam getting the results in the console application how i can get this entities into the wcf dataservice please tell me............
Posted
Updated 25-Apr-11 20:43pm
v2

1 solution

You could start with this[^] small tutorial. Just start placing your logic in this example and maybe you will get some results.

You could also try watching some quickstart vidoes on msdn or other websites.
 
Share this answer
 
Comments
Sandeep Mewara 26-Apr-11 5:01am    
OP has posted some code as an answer. (instead of comment). have a look.
Abhinav S 26-Apr-11 6:11am    
Thanks
MURARI00 22-Jun-11 4:54am    
Hi Abhinav i have problem regarding the wcf data service basic authentication i explained the the my problem in the following link please help me http://www.codeproject.com/Questions/214066/Regarding-the-wcf-data-service-basic-authenticatio please help me

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