Working_with_NHibernate_3_0.pdf
(
16437 KB
)
Pobierz
Join the discussion @
p2p.wrox.com
Wrox
Programmer to Programmer
™
Working
with
NHibernate 3.0
Benjamin Perkins
Working with NHibernate 3.0
Benjamin Perkins
John Wiley & Sons, Inc.
Working with NHibernate 3.0
Published by
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2011 by Wiley Publishing, Inc., Indianapolis, Indiana
ISBN: 978-1-118-10460-6
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means,
electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108
of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization
through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers,
MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to
the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011,
fax (201) 748-6008, or online at
http://www.wiley.com/go/permissions
.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with
respect to the accuracy or completeness of the contents of this work and speciically disclaim all warranties, including
without limitation warranties of itness for a particular purpose. No warranty may be created or extended by sales or
promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work
is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional
services. If professional assistance is required, the services of a competent professional person should be sought. Neither
the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Website is
referred to in this work as a citation and/or a potential source of further information does not mean that the author or the
publisher endorses the information the organization or Website may provide or recommendations it may make. Further,
readers should be aware that Internet Websites listed in this work may have changed or disappeared between when this
work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the
United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Trademarks:
Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are
trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its afiliates, in the United States and other coun-
tries, and may not be used without written permission. All other trademarks are the property of their respective owners.
Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this Wrox Blox.
This PDF should be viewed with Acrobat Reader 6.0 and later, Acrobat Professional 6.0 and later, or Adobe Digital Editions.
Usage Rights for Wiley Wrox Blox. Any Wiley Wrox Blox you purchase from this site will come with certain restrictions
that allow Wiley to protect the copyrights of its products. After you purchase and download this title, you:
• Are entitled to three downloads
• Are entitled to make a backup copy of the file for your own use
• Are entitled to print the Wrox Blox for your own use
• Are entitled to make annotations and comments in the Wrox Blox file for your own use
• May not lend, sell or give the Wrox Blox to another user
• May not place the Wrox Blox file on a network or any file sharing service for use by anyone other than yourself or
allow anyone other than yourself to access it
• May not copy the Wrox Blox file other than as allowed above
• May not copy, redistribute, or modify any portion of the Wrox Blox contents in any way without prior permission from
Wiley
If you have any questions about these restrictions, you may contact Customer Care at (877) 762-2974 (8 a.m. - 5 p.m.
EST, Monday - Friday). If you have any issues related to Technical Support, please contact us at 800-762-2974
(United States only) or 317-572-3994 (International) 8 a.m. - 8 p.m. EST, Monday - Friday).
Associate Publisher
Jim Minatel
Senior Project Editor
Ami Frank Sullivan
Technical Editor
Stephen Bolen
Production Editor
Daniel Scribner
Copy Editor
Luann Rouff
Editorial Manager
Mary Beth Wakeield
Production Manager
Tim Tate
Vice President and Executive Group Publisher
Richard Swadley
Vice President and Executive Publisher
Neil Edde
Proofreader
Nancy Carrasco
Indexer
Robert Swanson
ABOUT THE AUTHOR
Benjamin Delcamp Perkins
is currently employed at ISOware, GmbH in Munich,
Germany and has been working professionally in the IT industry for more than
16 years. He started computer programming with QBasic at the age of 11 on an
Atari 1200XL desktop computer. He takes pleasure in the challenges trouble
shooting technical issues offer and values the merit of a well written program. After
successfully completing his military service and serving in the Gulf War of 1990, he
received a Bachelor of Business Administration in Management Information Systems
from Texas A&M University.
His roles in the IT industry have spanned the entire spectrum from programmer, to system architect,
technical support engineer, to team leader and management. While employed at Hewlett-Packard,
he received numerous awards, degrees, and certiications. He has a passion for technology and
customer service. Benjamin enjoys sharing his C# and other programming experiences and has
created many free training videos which are available on YouTube. He also has an active blog
found at:
www.thebestcsharpprogrammerintheworld.com
.
“My approach is to write code with support in mind, and to write it once correctly and completely
so we do not have to come back to it again, except to enhance it.”
CONTENTS
CHAPTER 1: GETTING STARTED WITH NHIBERNATE 3
1
What Is an ORM?
2
Creating a Sample Project: The GuitarStore
3
Project Requirements
4
Creating the GuitarStore Solution
5
Creating the Database
7
Coniguring NHibernate
10
Downloading and Installing NHibernate
10
Creating the Class Files
11
Creating the Mapping Files
13
Mapping by Code
18
Understanding the property-ref Attribute
19
Coniguration Techniques
19
Creating a Console Application for Testing
28
Coniguring the GuitarStore WPF Program
30
Initializing NHibernate
30
Adding and Populating the DataGrid Control
30
Adding and Populating a ComboBox
33
Filtering the DataGrid Based on the ComboBox Selection
34
Understanding Lazy Loading
35
Coniguring Logging Using log4net
37
The Appender
38
The Logger
39
Coniguring Your Program to Use log4net
39
Serializing Startup
40
Serializing the Coniguration
42
Validating a Serialized Coniguration
42
Loading the Current Serialized Coniguration
43
Using a Serialized Coniguration
44
Timing the Startup
45
Interceptors and Events
46
Interceptors
46
Events
48
Implementing the Interceptor and Event Classes
49
Summary
52
Plik z chomika:
Phoob
Inne pliki z tego folderu:
NHibernate 3 Beginner's Guide_Code.rar
(50163 KB)
Working_with_NHibernate_3_0.pdf
(16437 KB)
NHibernate 3.0 Cookbook.pdf
(7171 KB)
NHibernate 3 Beginner's Guide.pdf
(6415 KB)
NHibernate in Action.pdf
(4783 KB)
Inne foldery tego chomika:
BizTalk 2010
Blend
c#
Certification
MCTS
Zgłoś jeśli
naruszono regulamin