samedi 29 mars 2014


Vote count:

0




Here is my ViewModel



public class CarViewModel
{
public string Registration { get; set; }
public string ModelName { get; set; }
public string Colour { get; set; }
public DateTime Year { get; set; }
}


Here is my Code



[HttpGet]
public ActionResult GetAllCars()
{
CarRentalEntities entities = new CarRentalEntities();
List<CarViewModel> carsViewModel = new List<CarViewModel>();
var cars = entities.GetAllCars();
// Is it possible to convert cars to carsViewModel Collection and
//return it to the view ????????????????
return View(carsViewModel);
}


Here is my SqlQuery which is called by EntityFramework



Create Procedure GetAllCars
as
(
Select c.registration,m.model_name,c.colour,m.model_year
from Cars c inner join models m
on c.model_id=m.model_id
)


In my EntityFramework Code All i want to do is Convert the collection returned by the sqlquery (GetAllCars)of type System.Data.Entity.Core.Object.ObjectResults into collection of type List. How can this be achieved? i couldn't find proper tutorial or articles. Hence its posted here. Thank you



asked 1 min ago

Sike12

136





Aucun commentaire:

Enregistrer un commentaire