Skip to content

Instantly share code, notes, and snippets.

@moaschterle
Created June 13, 2013 12:18
Show Gist options
  • Save moaschterle/5773244 to your computer and use it in GitHub Desktop.
Save moaschterle/5773244 to your computer and use it in GitHub Desktop.
// GET api/Poi/GetGolf
public IEnumerable<myGolf> GetGolf()
{
var mypoi = (from xy in db.PoiSet where xy.Primarytype == "golf"
select new myGolf
{
Id = xy.Id,
Poiname = xy.Nodename,
Region = xy.Region.RID,
Ort = xy.Ort.RID,
GPSEast = xy.PoiGps.Where(x => x.type == "position").FirstOrDefault().Gps.east,
GPSNorth = xy.PoiGps.Where(x => x.type == "position").FirstOrDefault().Gps.north,
GolfDetails = xy.PoiDetail.OfType<Golf>()
});
if (mypoi == null)
{
throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
}
return mypoi;
}
//Custom class
public class myGolf
{
public int Id { get; set; }
public string Poiname { get; set; }
public string Region { get; set; }
public string Ort { get; set; }
public string GPSEast { get; set; }
public string GPSNorth { get; set; }
public IEnumerable<Golf> GolfDetails { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment