Archive for the ‘Book Reviews’ category

Microsoft Entity Framework in Action Review

June 15th, 2010

I have been dipping into Microsoft’s Entity Framework

Microsoft Entity Framework in Action

Microsoft Entity Framework in Action

for a little while, but until now most of my EF applications have been pretty simple. For some of my current projects,I’ve wanted to get a better understanding of how the new version of EF works and gain insight into how it managed my data for me. I decided to get the MEAP version of Manning’s Microsoft Entity Framework in Action book by Stefano Mostarda and Marco De Sanctis and see what all it covered. After purchasing and using several MEAP books from Manning, I really think they are a great value and allow you to gain access to the texts before they have been published.

The book is broken into four parts, each building on the knowledge gained from the previous section. Part 1 of the book is an introduction to O/RMs and a quick guide as to what they provide developers. The coverage in this section is to help you get a better understanding of the Object/Relational Mismatch that occurs in applications and how solutions such as EF are developed to help with this mismatch. At the end of this section you will build the structure for a sample app that will be referenced throughout the book. This is a simple order application but it is used intelligently and explained in such a way that makes referencing it later helpful for understanding how EF usage is a benefit to the project.

Part 2 quickly starts diving into EF and guiding the reader through querying and understanding the model. In addition, it goes into the mechanics used for persistence and concurrency via EF. I’ll be referencing this section quite often due to all the examples that are included for dealing with data via querying, such as grouping, sorting and projecting results for ease of use. After the querying sections you are guided through the Entity Data Model (EDM) and how it is constructed and described using its different parts: Conceptual Model (CSDL), Storage Model (SSDL) and the Mapping (MSL). In most cases developers will use the Designer and the EDMX file generated in Visual Studio. Having an understanding of how the XML is built and how to build one manually, however, can really help when you want to make tweaks outside of the designer, such as extending the EDM with custom annotations.

In the last two chapters of this section the book goes into Persistence and Concurrency via EF. The persistence was one of the most interesting areas of the book for me (due to my DBA experiences). I think that too many times we use frameworks like EF without understanding the impact that some of our coding makes on the data store of our applications. These two sections give the reader a better understanding of how,and when, entities are marked in such a way that SQL calls will be made to the database for managing them. Having a better understanding of EntityState and ObjectStateManager can help a developer in mitigating the number of calls that will be made to the database by making sure that objects are marked correctly before calling SaveChanges methods. Also, through some of the techniques described for managing concurrency and transactions in your EF application, including managing entities in a disconnected manner, you can help ensure that the application works as expected.

Part 3 of the book focuses on some of the more advanced topics of EF including Entity SQL, usage of Functions and Stored Procedures in your model, querying the EDM programmatically, and customizing the EF code and designer. I was mainly interested the usage of Functions and Stored Procedures here. The book does a good job of providing the reader with several examples for mapping and consuming SPROCs from EF; including selecting data, updating entities and building functions that can be used against the inheritance hierarchy that you defined in your application.

The final section of the book walks you through bringing all of this new found EF knowledge together for building the order application. The authors did a good job of presenting not only their example application, but also providing the reader with meaningful information that can be used for building application architectures that use EF. Chapters include ASP .NET, Windows Applications and how to integrate EF with a traditional n-tier application. The last chapter provides helpful information on building unit tests against your EF enabled application.

I would recommend the book for those who are looking to increase their understanding of Microsoft’s Entity Framework. The book is not only a walk-through of how to build and use EF, it also provides the reader with a lot of reference material that can be used in day-to-day development work. I plan on referencing the “Working with Entity Framework” section quite often on my next project with EF in my attempts to streamline all data transactions that occur in my application when dealing with my entities.

C# in Depth, Second Edition by Jon Skeet

March 15th, 2010

skeet2_cover150

I just finished reading the MEAP version of Jon Skeet’s C# in Depth Second Edition from Manning Publishing. For those that are not familiar with Manning Early Access Program (MEAP) you can check it out here. The idea is that you can purchase a book, eBook or physical, and during the development of the book you get access to eBook drafts from the publisher. They have some great books/authors, and this gives you access to material before the book comes out. Handy if you are learning new technologies and do not want to wait.

I had not read the first edition and wanted to get caught up on some of the changes made to the framework for C# 4. The book is broken up into 4 main sections with a total of 16 chapters. The first section touches briefly on version 1 of C# and then each section builds on this foundation while introducing you changes in C# 2, 3 and 4 in the remaining sections.  At the time of this writing I was not able to read Chapter 1 and Appendixes due to them not being available via the MEAP program yet, but the meat and potatoes of the book were here.

 

The book flows differently than some of the other development books I have read. It walks you through where the language started and builds through the different versions and the improvements made with each. In the first chapters I was coming across a decent amount of "We will discuss this in 3.4" kind of references and generally I do not like this. For me, if a topic is being touched on why not go ahead and just tell me. But Skeet did a great job of giving a brief description as to why the topic is described later and once you get to the more advanced topic it makes sense.

 

This book does not strike me as a good book for beginners (but it wouldn’t hurt: keep reading) due to the depth that the author takes in explaining the challenges and changes made in previous versions of the framework. It is written to expect a certain level of experience with C# and the framework. I found times that I needed to do some research to make sure I understood what was being discussed. But if you are willing to do some extracurricular digging while reading the book you will be fine at any level and find yourself rewarded with a better understanding at the end.

 

The best part of the book is that Skeet keeps you involved and wanting to learn more. This is done by using several examples of the concepts being taught and then building on those concepts as you learn about the next version of the language. Also the book remains engaging due to the sprinkling of humor and explaining some less-than-recommended ways of using features.

 

Overall I would highly recommend this book for developers looking to gain knowledge of C# 4 and also to understand some of the “why” behind how we got to the current language feature set. Using Skeet’s style of building upon previous knowledge and deconstructing features in order to explain them, I found the chapters on Dynamic Binding and Code Contracts very engaging and they helped me to better understand these concepts in C# 4. This book will be staying on my kindle for awhile to use as a reference.