I want to retrieve some files using the contact id
here's my code.
public string Edit(int id)
{
var GetContacts = from c in db.Contacts where c.ContactID == id
select c;
return GetContacts.ToString();
}
when I go to contacts/edit/1 for example. it displays this.
System.Data.Objects.ObjectQuery`1[ContactsMVC.Models.Contact]
what is wrong with my code? is it in the query. I actually want to get the name, mobile, and email of the user.
I am new to asp.net C# mvc 2 so bear with me.
thanks in advance.
var GetContactsreturnsIEnumerable<Contact>so assuming you want that, then your method should bepublic IEnumerable<Contact>Edit(int id)(all you currently doing is returning theToString()value ofIEnumerable<Contact>)name,mobileandetc. from the object..var contact = (from c in db.Contacts where c.ContactID == id select c).FirstOrDefault();and then you change the method topublic Contact Edit(int id)(and access the properties of the model)public ActionResult Edit(int ID) { var contact = ...as above..; return View(contact); }