TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ankush Jassal
NA
10
3.8k
CRUD operation in asp.net mvc using WCF and Entity Framewrk
Sep 27 2014 10:43 AM
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.
Here's the code:-
IService1.cs:-
[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; }
}
}
Service1.cs:-
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.
Reply
Answers (
2
)
Help for paypal integration
hide/display using EditPostRenderCode in lightswitch