This print for content only-size & color not accurate 7" X 9-1/4" / casebound / malloy



Download 21,46 Mb.
Pdf ko'rish
bet1621/1830
Sana28.09.2021
Hajmi21,46 Mb.
#188411
1   ...   1617   1618   1619   1620   1621   1622   1623   1624   ...   1830
Bog'liq
[book] [en] Pro C# 2008 and the NET 3.5 Platform Fourth Edition

// Identify the primary key.

[Column(IsPrimaryKey = true)]

public int CarID;

public override string ToString()

{

return string.Format("ID = {0}; Make = {1}; Color = {2}; PetName = {3}",



CarID, Make.Trim(), Color.Trim(), PetName.Trim());

}

}



First of all notice that our entity class has been adorned with the [Table] attribute, while each

public field has been marked with [Column]. In both cases, the names are a direct mapping to the

physical database table. However, this is not a strict requirement, as the TableAttribute and

ColumnAttribute types both support a Name property that allows you to decouple your program-

matic representation of the data table from the physical table itself. Also notice that the CarID field

has been further qualified by setting the IsPrimaryKey property of the ColumnAttribute type using

named property syntax.

Here, for simplicity, each field has been declared publicly. If you require stronger encapsula-

tion, you could most certainly define private fields wrapped by public properties (or automatic

properties if you so choose). If you do so, it will be the 



property, not the fields, that will be marked

with the [Column] attribute.

It is also worth pointing out that an entity class can contain any number of members that do

not map to the data table it represents. As far as the LINQ runtime is concerned, only items marked

with LINQ to SQL attributes will be used during the data exchange. For example, this Inventory

class definition provides a custom implementation of ToString() to allow the application to quickly

display its state.

Now that we have an entity class, we can make use of the DataContext type to submit (and

translate) our LINQ query expressions to the specified database. Ponder the following Main()

method, which will display the result of all items in the Inventory table maintained by the AutoLot

database:

class Program

{

const string cnStr =



@"Data Source=(local)\SQLEXPRESS;Initial Catalog=AutoLot;" +

"Integrated Security=True";

static void Main(string[] args)

{

Console.WriteLine("***** LINQ to SQL Sample App *****\n");




Download 21,46 Mb.

Do'stlaringiz bilan baham:
1   ...   1617   1618   1619   1620   1621   1622   1623   1624   ...   1830




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2025
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