Podcast
Questions and Answers
What must be included in the signatures of properties in a data layer?
What must be included in the signatures of properties in a data layer?
What is the purpose of the mapping class in relation to an entity class?
What is the purpose of the mapping class in relation to an entity class?
What must the mapping class extend to function correctly with the context?
What must the mapping class extend to function correctly with the context?
What is required when migrating database schema changes?
What is required when migrating database schema changes?
Signup and view all the answers
How should the Build Action property be set for SQL files intended to be embedded?
How should the Build Action property be set for SQL files intended to be embedded?
Signup and view all the answers
What does the DatabaseScript table track?
What does the DatabaseScript table track?
Signup and view all the answers
Which method is recommended to improve performance when using ICollection.Contains() in a Where clause?
Which method is recommended to improve performance when using ICollection.Contains() in a Where clause?
Signup and view all the answers
What should be done after including a script in a project for it to run during bootstrapping?
What should be done after including a script in a project for it to run during bootstrapping?
Signup and view all the answers
What is the primary goal of the Configured Commerce data layer with respect to business logic?
What is the primary goal of the Configured Commerce data layer with respect to business logic?
Signup and view all the answers
What is the Default Object Relational Mapper (ORM) for Configured Commerce?
What is the Default Object Relational Mapper (ORM) for Configured Commerce?
Signup and view all the answers
Which namespace serves as the root for entity-related components in the Configured Commerce framework?
Which namespace serves as the root for entity-related components in the Configured Commerce framework?
Signup and view all the answers
How should entities typically be accessed in the data layer?
How should entities typically be accessed in the data layer?
Signup and view all the answers
What method is used to retrieve a specific entity by its primary key?
What method is used to retrieve a specific entity by its primary key?
Signup and view all the answers
Which statement accurately describes lazy loading in the context of the data layer?
Which statement accurately describes lazy loading in the context of the data layer?
Signup and view all the answers
Which option is recommended for getting a list of entities efficiently?
Which option is recommended for getting a list of entities efficiently?
Signup and view all the answers
What is the consequence of using the GetList method unadvisedly?
What is the consequence of using the GetList method unadvisedly?
Signup and view all the answers
What is the primary advantage of eager loading over lazy loading?
What is the primary advantage of eager loading over lazy loading?
Signup and view all the answers
What method is used to save an entity after it has been created?
What method is used to save an entity after it has been created?
Signup and view all the answers
To update an attached entity correctly, which of the following actions must be taken?
To update an attached entity correctly, which of the following actions must be taken?
Signup and view all the answers
What should you avoid doing when changing the data model?
What should you avoid doing when changing the data model?
Signup and view all the answers
What is necessary before you can add properties to a newly created entity class?
What is necessary before you can add properties to a newly created entity class?
Signup and view all the answers
What is a common reason to use the Include method in entity loading?
What is a common reason to use the Include method in entity loading?
Signup and view all the answers
What does deleting an entity typically involve?
What does deleting an entity typically involve?
Signup and view all the answers
Which of the following describes a POCO in the context of creating an entity class?
Which of the following describes a POCO in the context of creating an entity class?
Signup and view all the answers
Study Notes
Configured Commerce Data Layer Goals and Practices
- The data layer aims to use Entity Framework (EF) as the primary ORM.
- Efforts should be made to keep the data layer "thin", meaning entities should have minimal business logic.
- Business logic is primarily hosted within the service layer for better control and extensibility.
- The Insite.Data namespace serves as the root for entity-related components within the Configured Commerce framework.
Configured Commerce Data Layer Usage
- The recommended way to access data is through a UnitOfWork object and its corresponding Repository object.
- To retrieve an entity by ID, use the Get method on the appropriate repository, providing the primary key.
- Getting a list of entities is achieved through the GetTable method, returning an IQueryable object that can be filtered (where), sorted (orderby) or mapped (select).
- The GetList method can be used to execute custom SQL queries. However, it's important to use this method cautiously and only when necessary, as it retrieves data immediately.
- Lazy loading is enabled by default, retrieving related entities when accessed in the code. This results in multiple SQL calls.
- To optimize performance by loading related collections before usage, eager loading can be utilized through the Include method provided by Insite.Data.Extensions.
- Creating a new entity involves constructing an instance and calling the Insert method on the relevant repository.
- Updating an attached entity requires modifying the instance and calling the Save method on the UnitOfWork instance.
- Deleting an entity is accomplished by invoking the Delete method on the corresponding repository.
- Saving changes to the database requires calling the Save or SaveAsync method on the UnitOfWork object.
Configured Commerce Data Layer Extensibility
- Extending the data model is achieved by adding new entities to the model. Removal of Optimizely tables is not supported.
- Creating an entity class entails creating a POCO (Plain Old CLR Object) that extends from Insite.Data.Entities.EntityBase.
- Class properties should be "virtual" to accommodate lazy loading. It is recommended to avoid computed properties or methods, following the principle of a thin data layer.
- To map an entity, a mapping class needs to be created extending Insite.Data.Providers.EntityFramework.EntityMappings.EntityBaseTypeConfiguration.
- Custom mapping logic is primarily needed for many-to-many relationships between entities, following standard Entity Framework guidance.
- Database schema changes are not supported through migrations. Changes should be made through SQL files embedded in custom DLLs.
- SQL scripts are included in the build by setting the Build Action property to "Embedded Resource" and the Copy to Output Directory property to "Do not copy".
- Embedded SQL scripts are run automatically during the bootstrap operation. Successful execution adds an entry to the DatabaseScript table for auditing purposes.
Configured Commerce Data Layer Performance
- Using the Linq Where clause with ICollection.Contains() can significantly degrade application performance.
- Optimizely provides the WhereContains extension method, which offers a more performant solution for the same result.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
This quiz covers the key practices and goals of the Configured Commerce Data Layer, emphasizing the use of Entity Framework as the primary ORM. Participants will learn about the design principles for a thin data layer and the recommended access patterns through UnitOfWork and Repository objects.