public base_food GetFoodSite(DbGeometry inLocation) { base_food bf = null; using (DataMapsEntities me = new DataMapsEntities()) { bf = me.base_food.Where(g => g.geom.Contains(inLocation)).FirstOrDefault() as base_food; } return(bf); }
public void loadFoodFiles(string inFileName) { List <base_food> myFoodSites = new List <base_food>(); IFeatureSet fs = FeatureSet.Open(inFileName); DataTable dt = fs.DataTable; for (int i = 0; i < dt.Rows.Count; i++) { base_food food = new base_food(); IFeature f = fs.Features[i]; food.geom = DbGeometry.FromText(f.BasicGeometry.ToString()); food.PROBCAP = GetNullableDouble(dt.Rows[i], "PROBCAP"); food.SD_SIZE = GetLong(dt.Rows[i], "SD_SIZE"); food.X_SIZE = GetLong(dt.Rows[i], "X_SIZE"); myFoodSites.Add(food); } using (me = new MapEntites()) { me.Database.ExecuteSqlCommand("Truncate Table [base_food]"); me.base_food.AddRange(myFoodSites); me.SaveChanges(); } }