views:

42

answers:

1

My Table:

[LocationId]  
[Address]  
[ZipCode]

When I show a list of Location's, I also want to show the distance from a given zip code.
In Asp.Net Web Forms I had a stored procedure that would return the distance and I would call this SP on ItemDataBound on my GridView.

Or, I also would have my SP that is returning the Location list add another column ([Distance]) which I could display in my GridView.

How would you do this using Entity Framework and Asp.Net Mvc 2?

A: 

Me?

LocationPresentation model = Repository.Locations
                                       .Where(l => l.Id == someId)
                                       .AsEnumerable()
                                       .Select(l => new LocationPresentation
                                                    {
                                                        Id = l.Id,
                                                        Address = l.Address,
                                                        ZipCode = l.ZipCode,
                                                        Distance = DistanceLib.ComputeDistance(someZIP, l.ZipCode)
                                                     });
return View(model);
Craig Stuntz