Wei-Meng Lee - C# 2008 Programmer's Reference

Здесь есть возможность читать онлайн «Wei-Meng Lee - C# 2008 Programmer's Reference» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Город: Indianapolis, Год выпуска: 2009, ISBN: 2009, Издательство: Wiley Publishing, Inc., Жанр: Программирование, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

C# 2008 Programmer's Reference: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «C# 2008 Programmer's Reference»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

C# 2008 Programmers Reference provides a concise and thorough reference on all aspects of the language. Each chapter contains detailed code samples that provide a quick and easy way to understand the key concepts covered.

C# 2008 Programmer's Reference — читать онлайн бесплатно полную книгу (весь текст) целиком

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «C# 2008 Programmer's Reference», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать
Figure 1421 Because LINQ to SQL does not support cascadedelete operations - фото 210

Figure 14-21

Because LINQ to SQL does not support cascade-delete operations, you need to make sure that rows in related tables are also deleted when you delete a row. The following code example shows how to delete a title from the titlesand titleauthorstables:

DataClasses1DataContext database = new DataClasses1DataContext(); string titleid_to_remove = "BU5555";

//---find all associated row in Titles table---

var title = from t in database.titles

where t.title_id == titleid_to_remove select t;

//---delete the row in the Titles table---

foreach (var t in title)

database.titles.DeleteOnSubmit(t);

//---find all associated row in TitleAuthors table---

var titleauthor = from ta in database.titleauthors

where ta.title_id == titleid_to_remove select ta;

//---delete the row in the TitleAuthors table---

foreach (var ta in titleauthor)

database.titleauthors.DeleteOnSubmit(ta);

//---submit changes to database---

database.SubmitChanges();

Summary

This chapter, provides a quick introduction to the Language Integrated Query (LINQ) feature, which is new in .NET 3.5. It covered LINQ's four key implementations: LINQ to Objects, LINQ to XML, LINQ to Dataset, and LINQ to SQL. LINQ enables you to query various types of data sources, using a unified query language, making data access easy and efficient.

Chapter 15

Assemblies and Versioning

In .NET, the basic unit deployable is called an assembly. Assemblies play an important part of the development process where understanding how they work is useful in helping you develop scalable, efficient .NET applications. This chapter explores:

□ The components that make up a .NET assembly

□ The difference between single-file and multi-file assemblies

□ The relationships between namespaces and assemblies

□ The role played by the Global Assembly Cache (GAC)

□ How to develop a shared assembly, which can be shared by other applications

Assemblies

In .NET, an assembly takes the physical form of an EXE (known as a process assembly) or DLL (known as a library assembly) file, organized in the Portable Executable (PE) format. The PE format is a file format used by the Windows operating system for storing executables, object code, and DLLs. An assembly contains code in IL (Intermediate Language; compiled from a .NET language), which is then compiled into machine language at runtime by the Common Language Runtime (CLR) just-in-time compiler.

Structure of an Assembly

An assembly consists of the following four parts (see Figure 15-1).

Part Description
Assembly metadata Describes the assembly and its content
Type metadata Defines all the types and methods exported from the assembly
IL code Contains the MSIL code compiled by the compiler
Resources Contains icons, images, text strings, as well as other resources used by your application
Figure 151 Physically all four parts can reside in one physical file or - фото 211

Figure 15-1

Physically, all four parts can reside in one physical file, or some parts of an assembly can be stored other modules. A module can contain type metadata and IL code, but it does not contain assembly metadata. Hence, a module cannot be deployed by itself; it must be combined with an assembly to be used. Figure 15-2 shows part of an assembly stored in two modules.

Figure 152 An assembly is the basic unit of installation In this example - фото 212

Figure 15-2

An assembly is the basic unit of installation. In this example, the assembly is made up of three files (one assembly and two modules). The two modules by themselves cannot be installed separately; they must accompany the assembly.

Examining the Content of an Assembly

As mentioned briefly in Chapter 1, you can use the MSIL Disassembler tool ( ildasm.exe) to examine the content of an assembly. Figure 15-3 shows the tool displaying an assembly's content.

Figure 153 Among the various components in an assembly the most important - фото 213

Figure 15-3

Among the various components in an assembly, the most important is the manifest (shown as MANIFEST in Figure 15-3), which is part of the assembly metadata. The manifest contains information such as the following:

□ Name, version, public key, and culture of the assembly

□ Files belonging to the assembly

□ References assemblies (other assemblies referenced by this assembly)

□ Permission sets

□ Exported types

Figure 15-4 shows the content of the manifest of the assembly shown in Figure 15-3.

Figure 154 Single and MultiFile Assemblies In Visual Studio each - фото 214

Figure 15-4

Single and Multi-File Assemblies

In Visual Studio, each project that you create will be compiled into an assembly (either EXE or DLL). By default, a single-file assembly is created. Imagine you are working on a large project with 10 other programmers. Each one of you is tasked with developing part of the project. But how do you test the system as a whole? You could ask every programmer in the team to send you his or her code and then you could compile and test the system as a whole. However, that really isn't feasible, because you have to wait for everyone to submit his or her source code. A much better way is to get each programmer to build his or her part of the project as a standalone library (DLL). You can then get the latest version of each library and test the application as a whole. This approach has an added benefit — when a deployed application needs updating, you only need to update the particular library that needs updating. This is extremely useful if the project is large. In addition, organizing your project into multiple assemblies ensures that only the needed libraries (DLLs) are loaded during runtime.

To see the benefit of creating multi-file assemblies, let's create a new Class Library project, using Visual Studio 2008, and name it MathUtil. In the default Class1.cs, populate it with the following code:

using System;

using System.Collections.Generic;

using System.Linq;

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «C# 2008 Programmer's Reference»

Представляем Вашему вниманию похожие книги на «C# 2008 Programmer's Reference» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «C# 2008 Programmer's Reference»

Обсуждение, отзывы о книге «C# 2008 Programmer's Reference» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x