public object GetDistrictForSearch(string districtName, string countryId) { try { string district = string.Empty; int? countryIID; if (districtName != string.Empty || districtName != "") { district = districtName; } else { district = null; } if (countryId != string.Empty || countryId != "") { countryIID = Convert.ToInt32(countryId); } else { countryIID = null; } OiiOHaatDCDataContext db = DatabaseHelper.GetDataModelDataContext(); var retDistrict = (from lc in db.SP_GetDistrictForSearch(district, countryIID) select new { lc.DistrictID, lc.DistrictName, fullSearchDistrict = lc.DistrictName }).Take(10); //db.Dispose(); return(retDistrict); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }