none
Can this spatial web service that connects a database to Bing Maps using EF5 be used in a Windows 8 Store application. RRS feed

  • Question

  • Hello,

    Regarding my question in an earlier thread about connecting to a SQL Server Database to retrieve the locations, can we use this solution

    (http://blogs.msdn.com/b/rbrundritt/archive/2013/11/08/how-to-create-a-spatial-web-service-that-connects-a-database-to-bing-maps-using-ef5.aspx)

    This solution creates an spatial web service and then makes use of the Entity framework to retrieve data from SQL Server and display the same in Bing Maps. Can this web service be part of the solution that is created for Windows Store JavaScript application.

    Thanks,

    Rajesh.

    Wednesday, April 23, 2014 1:41 PM

Answers

  • For EF6 try loading it in using NuGet. In Visual Studios go to: Tools -> NuGet Package Manager -> Package Manager Console

    Then in the console type in the following:

    PM> Install-Package EntityFramework

    This will load in Entity Framework and all the required libraries.

    You will need to use LINQ to SQL in your web service to create the connection between your app and database. You will need to add a custom parameter in your REST service to specify the type of landmark.


    http://rbrundritt.wordpress.com

    • Proposed as answer by Ricky_Brundritt Wednesday, April 30, 2014 2:21 PM
    • Marked as answer by M.Rajesh Thursday, May 8, 2014 4:18 AM
    Wednesday, April 30, 2014 2:21 PM

All replies

  • Yes. Use the Spatial Toolbox to parse the Well Known Text and render it on the map: http://mapstoolbox.codeplex.com/

    I write about this in Chapter 7 of my free eBook on creating Location Intelligent Windows Store apps: http://rbrundritt.wordpress.com/my-book/


    http://rbrundritt.wordpress.com

    Wednesday, April 23, 2014 3:08 PM
  • Hello Ricky,

    When attempting to create the solution in Visual Studio 2013, I am prompted whether to use EF 5 or EF 6. Accidently I selected EF 6 and now I am getting this error

    The type or namespace name 'DBGeography' could not be found (are you missing a using directive or an assembly reference?). On searching for this error I found that the cause is " In EF 6, it's in System.Data.Spatial, which is part of EntityFramework.dll.  It was moved from System.Data.Entity since EF 5"

    I tried to search for a reference to EntityFramework.dll but it is not to be found from the dialog box. What should be done to fix this error. Should I go back to EF 5 and continue working on this solution.

    And when compiling the code for ServiceModels.cs I get this error "Error 2 Missing partial modifier on declaration of type 'BM_EF5_WebService.Common.Country'; another partial declaration of this type exists"

    namespace BM_EF5_WebService.Common
    {
        [DataContract]
        [KnownType(typeof(City))]
        [KnownType(typeof(Country))]
        public class BaseEntity
        {
            [DataMember]
            public string WKT { get; set; }
    
            [DataMember]
            public string Name { get; set; }
    
            [DataMember(EmitDefaultValue = false)]
            public double Distance { get; set; }
        }
    
        [DataContract]
        public class City : BaseEntity
        {
            [DataMember]
            public string CountryISO { get; set; }
    
            [DataMember]
            public int Population { get; set; }
        }
    
        [DataContract]
        public class Country : BaseEntity
        {
            public string ISO { get; set; }
    
            public int Population { get; set; }
        }
    
        [DataContract]
        public class Response
        {
            [DataMember]
            public List<BaseEntity> Results { get; set; }
    
            [DataMember(EmitDefaultValue = false)]
            public string Error { get; set; }
        }
    
        
    }

    On examining the code with the one in the article I found that the words City and Country are not recognized as keywords. Why is this so.

    Finally I want to implement this feature in my application.

    I want to display a drop down list box with "Type of Landmark". This can consist of the following, Church, Museum, Restaurant, Railway Station, etc etc. Data for each of the category along with their lat/long will be saved in SQL Server and when the user selects a particular value from the drop down list box, all the values from the database matching the landmark will be displayed on the map. How should that be achieved. Will I have to use LINQ to SQL to write the query for that. Kindly assist in this.

    Thanks,

    Rajesh.

    Wednesday, April 30, 2014 12:43 PM
  • For EF6 try loading it in using NuGet. In Visual Studios go to: Tools -> NuGet Package Manager -> Package Manager Console

    Then in the console type in the following:

    PM> Install-Package EntityFramework

    This will load in Entity Framework and all the required libraries.

    You will need to use LINQ to SQL in your web service to create the connection between your app and database. You will need to add a custom parameter in your REST service to specify the type of landmark.


    http://rbrundritt.wordpress.com

    • Proposed as answer by Ricky_Brundritt Wednesday, April 30, 2014 2:21 PM
    • Marked as answer by M.Rajesh Thursday, May 8, 2014 4:18 AM
    Wednesday, April 30, 2014 2:21 PM