I am performing crud operation in asp.net mvc 2 using wcf and entity framework and i am getting error in wcf "GetCustomer", the error is this "This operation is not supported in the WCF test client because it uses type WcfServiceLibrary5.customer." is disable and displaying red "exclamation mark" while other methods "insert", "update" and "delete" is enable.
[ServiceContract]
public interface IService1
{
[OperationContract]
List<customer> GetCustomer();
[OperationContract]
void InsertCustomer(Customer cust);
[OperationContract]
void DeleteCustomer(Customer cust);
[OperationContract]
void UpdateCustomer(Customer cust);
}
[DataContract]
public class Customer
{
int id;
[DataMember]
public int Id
{
get { return id; }
set { id = value; }
}
string firstname;
[DataMember]
public string Firstname
{
get { return firstname; }
set { firstname = value; }
}
string lastname;
[DataMember]
public string Lastname
{
get { return lastname; }
set { lastname = value; }
}
int age;
[DataMember]
public int Age
{
get { return age; }
set { age = value; }
}
}
public class Service1 : IService1
{
ankushEntities ae = new ankushEntities();
public List<customer> GetCustomer()
{
var query = from m in ae.customers select m;
return query.ToList<customer>();
}
public void InsertCustomer(Customer cust)
{
ae.AddTocustomers(cust);
ae.SaveChanges();
//cust.Id = cust.Id;
//cust.Firstname = cust.Firstname;
//cust.Lastname = cust.Lastname;
//cust.Age = cust.Age;
//ae.customers.AddObject(cust);
//ae.SaveChanges();
}
public void UpdateCustomer(Customer cust)
{
var v = ae.customers.FirstOrDefault(m => m.Id == cust.Id);
v.First_Name = cust.Firstname;
v.Last_Name = cust.Lastname;
v.Age = cust.Age;
ae.SaveChanges();
}
public void DeleteCustomer(Customer cust)
{
var v = ae.customers.FirstOrDefault(m => m.Id == cust.Id);
ae.customers.DeleteObject(v);
ae.SaveChanges();
}
}
Can anyone help me.