Book Image

Code-First Development with Entity Framework

By : Sergey Barskiy
Book Image

Code-First Development with Entity Framework

By: Sergey Barskiy

Overview of this book

<p>Entity Framework Code-First enables developers to read and write data in a relational database system using C# or VB.NET. It is Microsoft's answer to demand for an ORM from .NET developers.</p> <p>This book will help you acquire the necessary skills to program your applications using Entity Framework. You will start with database configuration and learn how to write classes that define the database structure. You will see how LINQ can be used with Entity Framework to give you access to stored data. You will then learn how to use Entity Framework to persist information in a Relational Database Management System. You will also see how you can benefit from writing ORM-based .NET code. Finally, you will learn how Entity Framework can help you to solve database deployment problems using migrations.</p>
Table of Contents (15 chapters)
Code-First Development with Entity Framework
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Chapter 5: Advanced Modeling and Querying Techniques


Q1. Since we are not creating a new entity, but a complex type, we need to use ComplexTypeConfiguration of the T base class to configure it.

Q2. The answer is false. We can use the ToTable method in order to configure an entity to be stored in a table with a name that is different from the class name for this entity.

Q3. The answer is false. We can use the Ignore method to exclude some properties from the persistence engine.

Q4. The process of selecting a subset of columns from a table, that is, a subset of properties from an entity, is called projection.

Q5. We do not have to declare a type for a result set; we can always use anonymous types.

Q6. We do not have to use joins to get related data in a query, since relationships exist in properties inside entities. Thus, related data is available inside a query by walking through these association properties.

Q7. In order to repeat parent entity data along with child data in the result set, we need to use SelectMany method of LINQ.

Q8. The set operator Distinct can be used to create a set of unique values from a query.

Q9. We cannot accomplish LEFT OUTER JOIN in LINQ with a single method.

Q10. The Skip and Take methods are used to accomplish paging. The Skip method, as the name implies, excludes some number of records from the result set, even though they match the filter. The Take method only takes a specified number of rows to include in the result set, even though more rows match the filter.

Q11. We can definitely create grouping queries based on multiple properties. We can typically use the anonymous type to specify which properties the grouped data is based on.