EntityFramework 学习 一 Spatial Data type support in Entity Framework 5.0

MS SQl Server引进两种特殊的数据类型geography and geometry

public partial class Course
{
    public Course()
    {
        this.Students = new HashSet<Student>();
    }
    
    public int CourseId { get; set; }
    public string CourseName { get; set; }
    public Nullable<int> TeacherId { get; set; }
    public System.Data.Spatial.DbGeography Location { get; set; }
    
    public virtual Teacher Teacher { get; set; }
    public virtual ICollection<Student> Students { get; set; }
}
     

 

 

using (var ctx = new SchoolDBEntities())
{
    ctx.Courses.Add(new Course() { CourseName = "New Course", 
                Location = DbGeography.FromText("POINT(-122.360 47.656)") });

    ctx.SaveChanges();
}
        

 

posted @ 2017-03-26 14:53  蓝平凡  阅读(315)  评论(0编辑  收藏  举报