售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
NHibernate 4.x Cookbook Second Edition
Table of Contents
NHibernate 4.x Cookbook Second Edition
Credits
About the Authors
About the Reviewer
www.PacktPub.com
eBooks, discount offers, and more
Why Subscribe?
Customer Feedback
Preface
What this book covers
What you need for this book
Who this book is for
Sections
Getting ready
How to do it…
How it works…
There's more…
See also
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. The Configuration and Schema
Introduction
Installing NHibernate
Getting ready
How to do it...
There's more…
Configuring NHibernate with hibernate.cfg.xml
Getting ready
How to do it...
How it works...
There's more...
NHibernate architecture
NHibernate properties
Dialects and drivers
See also
Configuring NHibernate with App.config or Web.config
Getting ready
How to do it…
How it works…
There's more…
See also
Configuring NHibernate with code
Getting ready
How to do it…
How it works…
There's more...
See also
Configuring NHibernate with Fluent NHibernate
Getting ready
How to do it…
How it works…
See also
Configuring NHibernate logging
Getting ready
How to do it...
How it works...
There's more...
Using logger to troubleshoot NHibernate
Using other log providers
See also
Generating the database
Getting ready
How to do it...
How it works...
There's more...
See also
Scripting the database
Getting ready
How to do it...
How it works...
See also
Updating the database
Getting ready
How to do it...
How it works...
See also
Using NHibernate schema tool
Getting ready
How to do it...
How it works...
There's more...
See also
2. Models and Mappings
Mapping a class with XML
Getting ready
How to do it…
How it works…
There's more…
What happens to these mappings?
Surrogate keys and natural IDs
ID generator selection
See also
Creating class hierarchy mappings
Getting ready
How to do it…
How it works…
There's more…
Table per class
Table per concrete class
See also
Creating class components
Getting ready
How to do it…
How it works…
Mapping a one-to-many relationship
Getting ready
How to do it…
How it works…
There's more…
Lazy loading collections
Lazy loading proxies
Collections
Bags
Lists
Sets
Map
See also
Mapping a many-to-many relationship
Getting ready
How to do it…
How it works…
There's more…
Mapping collections of elements and components
Getting ready
How to do it…
How it works…
There's more…
Setting up a base entity class
How to do it…
How it works…
There's more…
See also
Handling versioning and concurrency
Getting ready
How to do it…
How it works…
There's more…
See also
Mapping by code
Getting ready
How to do it…
How it works…
There's more…
See also
Mapping by convention
Getting ready
How to do it…
How it works…
There's more…
Creating mappings fluently
Getting ready
How to do it…
How it works…
See also
Bidirectional one-to-many class relationships
How to do it…
How it works…
There's more…
Mapping enumerations
How to do it…
How it works…
Unnecessary updates
See also
Immutable entities
Getting ready
How to do it…
How it works…
Mapping relations to non-primary keys
Getting ready
How to do it…
How it works…
There's more…
Using lazy properties
Getting ready
How to do it…
How it works…
Mapping joins
Getting ready
How to do it…
How it works…
There's more…
Using calculated properties
Getting ready
How to do it…
How it works…
There's more…
Using serializable values
Getting ready
How to do it…
How it works…
There's more…
Dynamic components
Getting ready
How to do it…
How it works…
There's more…
Mapping <subselect>
Getting ready
How to do it…
How it works…
3. Sessions and Transactions
Introduction
Setting up session-per-web request
Getting ready
Option 1: Using the companion library
Option 2: Manual setup
How to do it…
How it works…
There's more…
See also
Setting up session-per-presenter
How to do it…
How it works…
There's More…
See also
Creating a session ASP.NET MVC action filter
Getting ready
How to do it…
How it works…
What about Web API?
There's more…
View models
See also
Creating a transaction ASP.NET MVC action filter
Getting ready
How to do it…
How it works…
There's more…
Save entities to the database
Getting ready
How to do it…
How it works…
Save
Update
SaveOrUpdate
Persist
Using different flush modes
Commit
Auto
Always
Never
Using session.Merge
Getting ready
How to do it…
How it works…
See also
Using session.Refresh
Getting ready
How to do it…
How it works…
There's more…
See also
Handle concurrency using session.Lock
Getting ready
How to do it…
How it works…
None
Read
Upgrade
UpgradeNoWait
There's more…
Using dictionaries as entities
Getting ready
How to do it...
How it works…
There's more…
Partially dynamic
Using NHibernate with transaction scope
Getting ready
How to do it…
How it works…
See also
4. Queries
Introduction
Getting ready
Query entities by ID
Getting ready
How to do it…
How it works…
Session.Get
Session.Load
The session cache jumps in
Using LINQ to NHibernate
Getting ready
How to do it…
How it works…
There's more…
See also
Using CriteriaQueries
Getting ready
How to do it…
How it works…
There's more…
See also
Using QueryOver
Getting ready
How to do it…
How it works…
There's more…
See also
Using QueryOver projections and aggregates
Getting ready
How to do it…
How it works…
See also
Using the Hibernate Query Language
Getting ready
How to do it…
How it works…
There's more…
See also
Using native SQL
Getting ready
How to do it…
How it works…
Eager loading with LINQ
Getting ready
How to do it…
How it works…
There's more…
Limiting the result set doesn't work
Eager loading multiple collections should be avoided
Use batching as an alternative solution
See also
Eager loading with Criteria
Getting ready
How to do it…
How it works…
Eager loading with QueryOver
Getting ready
How to do it…
How it works…
Eager loading with HQL
Getting ready
How to do it…
How it works…
Eager loading with SQL
Getting ready
How to do it…
How it works…
Using named queries
Getting ready
How to do it…
How it works…
Named SQL queries
There's more…
See also
Using detached queries
Getting ready
How to do it…
How it works…
There's more…
See also
Using HQL for bulk data changes
Getting ready
How to do it…
How it works…
There's more…
Bulk inserts
See also
Filtering collections
Getting ready
How to do it…
How it works…
There's more…
Using result transformers
How to do it…
How it works…
There's more…
DistinctRootEntity
AliasToEntityMap
PassThrough
RootEntity
ToList
AliasToBean
AliasToBeanConstructor
Creating your own transformer
Extra lazy collections
Getting ready
How to do it…
How it works…
There's more…
5. Improving Performance
Reducing application startup time
Getting ready
How to do it…
How it works…
There's more…
Using MultiCriteria
Getting ready
How to do it…
How it works…
See also
Using MultiQuery
Getting ready
How to do it…
How it works…
See also
Using Futures
Getting ready
How to do it...
How it works...
There's more...
See also
Eager loading child collections
Getting ready
How to do it...
How it works...
Problem 1 – limiting the result set doesn't work
Problem 2 – only the queried class' properties can be eager loaded
Problem 3 – eager loading multiple collections should be avoided
There's more…
Criteria
QueryOver
See also
Using stateless sessions
Getting ready
How to do it...
How it works...
There's more...
Using read-only entities
Getting ready
How to do it...
How it works...
Setting the session to be read-only
Setting a query to load entities as read-only
Making a specific entity read-only
There's more...
Use the second-level cache
Getting ready
How to do it...
How it works...
There's more...
Entity cache
Query cache
Update timestamp cache
The rules
See also
Configuring the second-level cache with code
Getting ready
How to do it...
How it works...
There's more…
See also
Sharding databases for performance
Getting ready
How to do it...
How it works...
6. Testing
Introduction
Using NHibernate Profiler
Getting ready
How to do it...
How it works...
There's more...
See also
Profiling NHibernate with Glimpse
Getting ready
How to do it...
How does it work...
See also
Fast testing with the SQLite in-memory database
Getting ready
How to do it...
How it works...
There's more...
See also
Preloading data with SQLite
Getting ready
How to do it...
How it works...
There's more...
See also
Using Fluent NHibernate persistence testing
Getting ready
How to do it...
How it works...
See also
Using the Ghostbusters test
Getting ready
How to do it...
How it works...
See also
7. Data Access Layer
Introduction
Transaction auto-wrapping for the data access layer
Getting ready
How to do it…
How it works…
There's more…
See also
Setting up an NHibernate repository
Getting ready
How to do it…
How it works…
There's more…
See also
Using named queries in the data access layer
Getting ready
How to do it…
How it works…
See also
Using ICriteria in the data access layer
Getting ready
How to do it…
How it works…
There's more…
See also
Using paged queries in the data access layer
Getting ready
How to do it…
How it works…
See also
Using LINQ specifications in the data access layer
Getting ready
How to do it…
How it works…
There's more…
Specification composition
See also
8. Extending NHibernate
Introduction
Creating an encrypted string type
How to do it…
How it works…
There's more…
See also
Creating a money type
How to do it…
How it works…
There's more…
See also
Using well-known instance types
How to do it…
How it works…
See also
Using dependency injection with entities
Getting ready
How to do it…
How it works…
There's more…
Bland passwords need salt
See also
Creating an audit-event listener
How to do it…
How it works…
There's more…
See also
Creation and change stamping of entities
How to do it…
How it works…
See also
Generating trigger-based auditing
Getting ready
How to do it…
How it works…
See also
Implementing a soft-delete pattern
How to do it…
How it works…
There's more…
See also
Setting Microsoft SQL's Context_Info
Getting ready
How to do it…
How it works…
See also
Using dynamic connection strings
How to do it…
How it works…
See also
Using custom dialect functions
How to do it…
How it works…
See also
Using custom functions in LINQ
Getting ready
How to do it…
How it works…
See also
Extending the LINQ provider
Getting ready
How to do it…
How it works…
See also
9. NHibernate Contribution Projects
Introduction
Property validation with attributes
Getting ready
How to do it…
How it works…
There's more…
See also
Creating validator classes
Getting ready
How to do it…
How it works…
There's more…
See also
Setting up full-text searches
Getting ready
How to do it…
How it works…
There's more…
Auditing data with Envers
Getting ready
How to do it…
How it works…
There's more…
See also
Using NHibernate Spatial
Getting ready
How to do it…
How it works…
There's more…
Geography or geometry?
What's this SRID?
Spatial data types
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜