Spatial type maintain was introduced in Entity Framework 5. A set of operators is also integrated to permit queries to analyze spatial data. For instance, a query can filter based on the distance between two geographic location.
There are two most important spatial data types −
Let’s take a look into the following instance of Cricket ground.
Step 1 − Create new project from File → New → Project menu option.
Step 2 − In the left panel select the Console Application.
Step 3 − Right-click on project name and select Manage NuGet Packages…
Step 4 − Install Entity Framework.
Step 5 − Add reference to System.Data.Entity meeting and also add the System.Data.Spatial using statement for spatial data types.
Step 6 − Add the following class in Program.cs file.
Step 7 − In addition to significant entities, you need to define a class that derives from DbContext and exposes DbSet<TEntity> properties.
In the Program.cs add the context explanation.
Step 8 − Add the following code into the Main function, which will add two new CricketGround things to the context.
Spatial properties are initialized by using the DbGeography.FromText method. The geography point represent as WellKnownText is passed to the method and then saves the data. After that Cricket Ground object will be retrieve where its location is closest to the particular location.
When the above code is execute, you will accept the following output –
We recommend that you execute the above example in a step-by-step method for better accepting.
Microsoft Entity Framework Related Interview Questions
|XML Interview Questions||HTML 5 Interview Questions|
|Microsoft Entity Framework Interview Questions||Framework7 Interview Questions|
|Oracle Performance Tuning Interview Questions||Windows Presentation Foundation(WPF) Interview Questions|
|Windows Communication Foundation (WCF) Interview Questions||Microsoft Foundation Class Library (MFC) Interview Questions|
|Net Micro Framework Interview Questions|
Microsoft Entity Framework Related Practice Tests
|XML Practice Tests||HTML 5 Practice Tests|
|Microsoft Entity Framework Practice Tests||Windows Presentation Foundation(WPF) Practice Tests|
|Windows Communication Foundation (WCF) Practice Tests|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.