没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
试读
536页
Entity Framework 6 Recipes provides an exhaustive collection of ready-to-use code solutions for Entity Framework, Microsoft's model-centric, data-access platform for the .NET Framework and ASP.NET development. With this book, you will learn the core concepts of Entity Framework through a broad range of clear and concise solutions to everyday data access tasks. Armed with this experience, you will be ready to dive deep into Entity Framework, experiment with new approaches, and develop ways to solve even the most difficult data access challenges. If you are a developer who likes to learn by example, then this is the right book for you.
资源推荐
资源详情
资源评论
Driscoll
Gupta
Vettor
Hirani
Tenny
Shelve in
Databases/MS SQL Server
User level:
Intermediate–Advanced
www.apress.com
SOURCE CODE ONLINE
BOOKS FOR PROFESSIONALS BY PROFESSIONALS
®
Entity Framework 6 Recipes
Entity Framework 6 Recipes provides an exhaustive collection of ready-to-use code
solutions for Entity Framework, Microsoft’s model-centric, data-access platform for the
.NET Framework and ASP.NET development. With this book, you will learn the core
concepts of Entity Framework through a broad range of clear and concise solutions
to everyday data access tasks. Armed with this experience, you will be ready to dive
deep into Entity Framework, experiment with new approaches, and develop ways to
solve even the most difficult data access challenges. If you are a developer who likes
to learn by example, then this is the right book for you.
• Gives ready-to-use, real-world recipes to help you with everyday tasks
• Places strong focus on DbContext and the Code First approach
• Covers new features such as Asynch Query and Save, Codebased Configuration,
Connection Resiliency, Dependency Resolution, and much more
What You’ll Learn
• Implement basic data access design patterns using Entity Framework
• Seamlessly model your solutions across both code and data
• Provide data access to Windows 8 and Metro applications
• Integrate with WCF Data Services
• Improve data access performance
• Simplify and reduce your code through data binding
SECOND
EDITION
RELATED
9 781430257882
ISBN 978-1-4302-5788-2
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
This book was purchased by rick@hubka.com
v
Contents at a Glance
About the Authors ����������������������������������������������������������������������������������������������������������� xxvii
About the Technical Reviewer ����������������������������������������������������������������������������������������� xxix
Preface ���������������������������������������������������������������������������������������������������������������������������� xxxi
Chapter 1: Getting Started with Entity Framework ■ �����������������������������������������������������������1
Chapter 2: Entity Data Modeling Fundamentals ■ ��������������������������������������������������������������11
Chapter 3: Querying an Entity Data Model ■ �����������������������������������������������������������������������55
Chapter 4: Using Entity Framework in ASP�NET MVC ■ �����������������������������������������������������107
Chapter 5: Loading Entities and Navigation Properties ■ �������������������������������������������������129
Chapter 6: Beyond the Basics with Modeling and Inheritance ■ ��������������������������������������183
Chapter 7: Working with Object Services ■ ����������������������������������������������������������������������235
Chapter 8: Plain Old CLR Objects ■ �����������������������������������������������������������������������������������257
Chapter 9: Using the Entity Framework in N-Tier Applications ■ �������������������������������������295
Chapter 10: Stored Procedures ■ �������������������������������������������������������������������������������������341
Chapter 11: Functions ■ ���������������������������������������������������������������������������������������������������375
Chapter 12: Customizing Entity Framework Objects ■ �����������������������������������������������������413
Chapter 13: Improving Performance ■ �����������������������������������������������������������������������������451
Chapter 14: Concurrency ■ �����������������������������������������������������������������������������������������������483
Index ���������������������������������������������������������������������������������������������������������������������������������503
1
Chapter 1
Getting Started with Entity Framework
When working with relational databases, we think in terms of tables with rows and columns. Tables are highly
structured and excel at set-based processing. Before the wide adoption of object-oriented programming, we thought
about problems “procedurally” and solved them by writing code in a structured, top-down manner, function after
function. Both worlds lined up well: Tables, rows, and columns closely matched the structured and procedural
patterns in our code. Life was good - for a time ...
Much has evolved on the code side. We now think in terms of objects and domain models. We architect,
design, and program against real-world things, like customers and orders. We draw nouns in our problem space
on whiteboards. We draw lines between them, denoting relationships and interactions. We build specifications
and assign work to development teams in terms of these drawings. In short, we architect, design, and program at a
conceptual level that is very distant from the logical and physical organization of the database.
While the software development process has dramatically matured and the way in which we reason and
solve problems has evolved, the database has not. The data remains locked in the same tables, rows, and columns
paradigm, where it has been for many years. Unfortunately, this creates a mismatch (an impedance mismatch, as
Microsoft fellow Anders Hejlsberg might call it): Object-oriented class hierarchies vs. a highly normalized database
structure.
To cope with this gap, software projects often introduce a “database layer” that translates application domain
classes into the rows and columns saved in tables. This approach has spawned many commercial and open-source
data access frameworks; all attempting to bridge the ever widening gap between evolving development processes and
structured data. Interestingly, an entire new field of Object Relational Mapping (ORM) has come out it.
The Entity Framework, coupled with the Language-Integrated Query (LINQ) framework, both from Microsoft,
enables us to address the mismatch problem head-on. Using Entity Framework, we model entity classes for our
application on a design surface or directly in code. Then we model relationships (associations) between these entities.
In our code, we construct LINQ queries to program against these entities and associations. LINQ allows us to express
relational database set concepts directly into our code while working in terms of entity types and associations. All
of this helps to streamline our development experience while reducing the overall effort. Instead of coding large
numbers of highly redundant ADO.NET data access constructs, we express our data needs in simple LINQ queries.
Instead of programming against the schema of a highly normalized database, we code against entity classes. Entity
Framework maps entity classes to the underlying database for you.
Note ■ We use the term entity class or entity object to refer to a class that typically represents a domain item in an
application. Domain classes represent real-world objects, such as an Employee, Department, or Manager, which your
application will represent and track. The end users and stakeholders of your application should be able to look at the
domain classes in your application and say, “Yes, that’s what our business does.” Entity classes define the schema,
or properties, but not the behavior, of a domain class. In essence, entity classes expose the state of an object.
CHAPTER 1 ■ GETTING STARTED WITH ENTITY FRAMEWORK
2
1-1. A Brief Tour of the Entity Framework World
Entity Framework is Microsoft’s strategic approach to data access technology for building software applications.
Unlike earlier data access technologies, Entity Framework, coupled with Visual Studio, delivers a comprehensive,
model-based ecosystem that enables you to develop a wide range of data-oriented applications, including desktop,
Internet, cloud, and service-based applications, many of which will be covered in this book.
The History
Entity Framework is not new. The product dates back to Visual Studio 2008 and has come a long way in features and
functionality. Figure 1-1 gives the pictorial history.
The first version of Entity Framework was limited, featuring basic ORM support and the ability to implement
a single approach known as Database First, which we thoroughly demonstrate in this book. Version 4 brought us
another approach to using Entity Framework: Model First, along with full Plain Old CLR Object (POCO) support and
default lazy loading behavior. Soon after, the Entity Framework team released three smaller, or point releases, 4.1
through 4.3, which represented yet another approach to using Entity Framework: Code First. As shown above,
Version 5 of Entity Framework coordinated with the release of the .NET 4.5 framework and Visual Studio 2012,
delivering significant performance improvements along with support for enums, table value functions, spatial types,
the batch import of stored procedures, and deep support with the ASP.NET MVC framework.
Now we are at Version 6 of the Entity Framework. Version 6 delivers asynchronous support for querying and
updates, stored procedure support for updates in Code First, improved performance, and a long list of new features,
which we will focus on in this book.
Figure 1-1. A short history of the Entity Framework
剩余535页未读,继续阅读
laoge
- 粉丝: 1203
- 资源: 319
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于51单片机的自动浇花设计论文
- 客服机器人需要的数据集,包括order、ware、user,测试集和开发集
- 用0到9生成十位数的所有排列组合(java代码).docx
- 模仿魔慢相机的人脸监测选择ios组件
- STM32F103C8T6模拟IIC控制4针0.96寸OLED显示屏已测
- Chromeextent_paly.zip
- 【2023年全国职业技能大赛“信息安全与评估”赛项】任务4-Linux内存取证WP+靶场环境
- 基于51单片机数字电压表的设计(PCB+原理图+仿真+论文+代码)
- open62541在window10 VS2019编译完成的源码
- 新闻文章自动新闻采集系统-webapps.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页