コード例 #1
0
        private void AddMapPoint(int tripId, MapPoint point, int sequence)
        {            
            var parameters = new[]
            {
               new SqlParameter(SpParams.AddMapPoint.TripId, tripId) { Direction = ParameterDirection.Input, DbType = DbType.Int32 },
               new SqlParameter(SpParams.AddMapPoint.Latitude, point.Latitude) { Direction = ParameterDirection.Input, DbType = DbType.Double },
               new SqlParameter(SpParams.AddMapPoint.Longitude, point.Longitude) { Direction = ParameterDirection.Input, DbType = DbType.Double },               
               new SqlParameter(SpParams.AddMapPoint.FormattedLongAddress, point.FormattedLongAddress) { Direction = ParameterDirection.Input, DbType = DbType.String },
               new SqlParameter(SpParams.AddMapPoint.FormattedShortAddress, point.FormattedShortAddress) { Direction = ParameterDirection.Input, DbType = DbType.String },
               new SqlParameter(SpParams.AddMapPoint.Sequence, sequence) { Direction = ParameterDirection.Input, DbType = DbType.Int32 },

               new SqlParameter(SpParams.AddMapPoint.City, point.AddressDetails.City) { Direction = ParameterDirection.Input, DbType = DbType.String },
               new SqlParameter(SpParams.AddMapPoint.District, point.AddressDetails.District) { Direction = ParameterDirection.Input, DbType = DbType.String },
               new SqlParameter(SpParams.AddMapPoint.Region, point.AddressDetails.Region) { Direction = ParameterDirection.Input, DbType = DbType.String },
               new SqlParameter(SpParams.AddMapPoint.Country, point.AddressDetails.Country) { Direction = ParameterDirection.Input, DbType = DbType.String },
               new SqlParameter(SpParams.AddMapPoint.StreetName, point.AddressDetails.StreetName) { Direction = ParameterDirection.Input, DbType = DbType.String },
               new SqlParameter(SpParams.AddMapPoint.StreetNumber, point.AddressDetails.StreetNumber) { Direction = ParameterDirection.Input, DbType = DbType.String },
            };

            point.Sequence = sequence;
            point.Id = ExecuteScalar(SpNames.AddMapPoint, parameters);
        }
コード例 #2
0
        private MapPoint PopulateMapPoint(SqlDataReader dataReader)
        {
            var mapPoint = new MapPoint()
            {
                Id = dataReader["Id"].FromDb<int>(),
                Sequence = dataReader["Sequence"].FromDb<int>(),
                Latitude = dataReader["Latitude"].FromDb<double>(),
                Longitude = dataReader["Longitude"].FromDb<double>(),
                FormattedLongAddress = dataReader["FormattedLongAddress"].FromDb<string>(),
                FormattedShortAddress = dataReader["FormattedShortAddress"].FromDb<string>(),
                AddressDetails = new Address()
                {
                    City = dataReader["City"].FromDb<string>(),
                    Country = dataReader["Country"].FromDb<string>(),
                    District = dataReader["District"].FromDb<string>(),
                    Region = dataReader["Region"].FromDb<string>(),
                    StreetName = dataReader["StreetName"].FromDb<string>(),
                    StreetNumber = dataReader["StreetNumber"].FromDb<string>()
                }
            };

            return mapPoint;
        }
コード例 #3
0
        private void AddMapPoint(int tripId, MapPoint point, int sequence)
        {
            point.TripId = tripId;
            point.Sequence = sequence;

            CatchMeContext.MapPoints.Add(point);
            CatchMeContext.Addresses.Add(point.AddressDetails);

            CatchMeContext.SaveChanges();
        }