コード例 #1
0
        //for search location
        public object GetLocationForSearch(string locationName, string policeStationId, string districtId, string countryId)
        {
            try
            {
                string location = string.Empty;
                Int64? policeStationIID;
                Int64? districtIID;
                int?   countryIID;

                if (locationName != string.Empty || locationName != "")
                {
                    location = locationName;
                }
                else
                {
                    location = null;
                }
                if (policeStationId != string.Empty || policeStationId != "")
                {
                    policeStationIID = Convert.ToInt64(policeStationId);
                }
                else
                {
                    policeStationIID = null;
                }
                if (districtId != string.Empty || districtId != "")
                {
                    districtIID = Convert.ToInt64(districtId);
                }
                else
                {
                    districtIID = null;
                }
                if (countryId != string.Empty || countryId != "")
                {
                    countryIID = Convert.ToInt32(countryId);
                }
                else
                {
                    countryIID = null;
                }

                OiiOHaatDCDataContext db = DatabaseHelper.GetDataModelDataContext();
                var retLocation          = (from lc in db.SP_GetLocationForSearch(location, policeStationIID, districtIID, countryIID)
                                            select new
                {
                    lc.LocationID,
                    lc.DistrictID,
                    lc.DistrictName,
                    lc.PoliceStationID,
                    lc.PoliceStationName,
                    lc.CurrentLocationName,
                    fullSearchLocation = (lc.DistrictName + ", " + lc.PoliceStationName + ", " + lc.CurrentLocationName)
                }).Take(10);
                //db.Dispose();
                return(retLocation);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }