Customization Custom Entities
24 Questions
5 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What must be included in the signatures of properties in a data layer?

  • Primitive types
  • Entity reference
  • Virtual keyword (correct)
  • Computed properties
  • What is the purpose of the mapping class in relation to an entity class?

  • To outline custom relationships (correct)
  • To create entity logic
  • To manage user interface elements
  • To define standard database constraints
  • What must the mapping class extend to function correctly with the context?

  • EntityBaseTypeConfiguration (correct)
  • DbContext
  • CustomRepositoryBase
  • Entity Framework Core
  • What is required when migrating database schema changes?

    <p>Manual SQL file scripts</p> Signup and view all the answers

    How should the Build Action property be set for SQL files intended to be embedded?

    <p>Embedded Resource</p> Signup and view all the answers

    What does the DatabaseScript table track?

    <p>All executed scripts</p> Signup and view all the answers

    Which method is recommended to improve performance when using ICollection.Contains() in a Where clause?

    <p>WhereContains</p> Signup and view all the answers

    What should be done after including a script in a project for it to run during bootstrapping?

    <p>Set it to Do not copy</p> Signup and view all the answers

    What is the primary goal of the Configured Commerce data layer with respect to business logic?

    <p>To minimize business logic in the data layer</p> Signup and view all the answers

    What is the Default Object Relational Mapper (ORM) for Configured Commerce?

    <p>Entity Framework</p> Signup and view all the answers

    Which namespace serves as the root for entity-related components in the Configured Commerce framework?

    <p>Insite.Data</p> Signup and view all the answers

    How should entities typically be accessed in the data layer?

    <p>By obtaining a UnitOfWork object and a Repository</p> Signup and view all the answers

    What method is used to retrieve a specific entity by its primary key?

    <p>Get</p> Signup and view all the answers

    Which statement accurately describes lazy loading in the context of the data layer?

    <p>It loads related entities only when they are accessed.</p> Signup and view all the answers

    Which option is recommended for getting a list of entities efficiently?

    <p>Using the GetTable method with sorting and filtering</p> Signup and view all the answers

    What is the consequence of using the GetList method unadvisedly?

    <p>It can result in excessive data load and performance issues.</p> Signup and view all the answers

    What is the primary advantage of eager loading over lazy loading?

    <p>Eager loading allows for only one SQL call.</p> Signup and view all the answers

    What method is used to save an entity after it has been created?

    <p>Save or SaveAsync</p> Signup and view all the answers

    To update an attached entity correctly, which of the following actions must be taken?

    <p>Update the instance and call Save or SaveAsync.</p> Signup and view all the answers

    What should you avoid doing when changing the data model?

    <p>Removing Optimizely tables.</p> Signup and view all the answers

    What is necessary before you can add properties to a newly created entity class?

    <p>Extending from Insite.Data.Entities.EntityBase.</p> Signup and view all the answers

    What is a common reason to use the Include method in entity loading?

    <p>To load collections ahead of time when necessary.</p> Signup and view all the answers

    What does deleting an entity typically involve?

    <p>Calling the Delete method and Save or SaveAsync.</p> Signup and view all the answers

    Which of the following describes a POCO in the context of creating an entity class?

    <p>A class that extends from EntityBase.</p> 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.

    Quiz Team

    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.

    More Like This

    ASP
    10 questions

    ASP

    DetachableCognition avatar
    DetachableCognition
    Entity Framework Query Operations Quiz
    16 questions
    Entity Framework Fundamentals
    10 questions
    Use Quizgecko on...
    Browser
    Browser