Guide to Entity Framework with



Download 11,91 Mb.
Pdf ko'rish
bet33/48
Sana30.03.2022
Hajmi11,91 Mb.
#517122
TuriGuide
1   ...   29   30   31   32   33   34   35   36   ...   48
Bog'liq
Entity Framework Tutorial, Second Edition (1)

[
 26 
]
Enum support
Enum support is a much-awaited feature that enables you to have enum properties 
in your domain classes. In Entity Framework 6, you have enum support both in 
the EF Designer as well as using a code-first approach. To create an enum in Entity 
Framework 6, all you need is to create a scalar property of type 
Int32
in the EDM, 
select it, right-click on it, and then select 
Convert to Enum
. The following image 
illustrates this:
In the preceding image, 
IsRetired
has been introduced as a scalar property of type 
Int32
. You can see that the 
Convert to Enum
option is enabled.


Chapter 1
[
 27 
]
Spatial data types support
Spatial data types are actually geography and geometry-related classes that allow 
us to work directly with such data inside the SQL Server. Spatial data can be of two 
types—the 
geometry data type
that provides support for planar or Euclidean (flat-
earth) data, and 
geography data type
that can store ellipsoidal (round-earth) data 
such as GPS latitude and longitude coordinates. Entity Framework 6 now provides 
support for spatial data types using the 
DbGeography
and 
DbGeometry
types. You 
can include spatial data in your models both using the EF Designer, as well as
using code-first. You can find out more about spatial data types
from this link: 
http://technet.microsoft.com/en-us/library/bb964711.aspx
.
Some of the new features in Entity Framework 6 such as enum support 
and spatial data types will work with .NET Framework 4.5 and above.
Other enhancements
In Entity Framework 6, 
DbContext
is the default generated context. It is not new 
though. It is a wrapper around 
ObjectContext
generated using T4 templates.
Here is an example:
public AdventureWorksEntities()
: base("name=AdventureWorksEntities")
{
}
protected override void OnModelCreating(DbModelBuilder 
modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public virtual DbSet Departments { get; set; }
public virtual DbSet Employees { get; set; }
public virtual DbSet 
EmployeeDepartmentHistories { get; set; }
public virtual DbSet 
EmployeePayHistories { get; set; }
public virtual DbSet JobCandidates { get; 
set; }
public virtual DbSet Shifts { get; set; }
}


Introducing the ADO.NET Entity Framework

Download 11,91 Mb.

Do'stlaringiz bilan baham:
1   ...   29   30   31   32   33   34   35   36   ...   48




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish