GithubHelp home page GithubHelp logo

introtoefexample's Introduction

IntroToEFExample

Introduction

IntroToEFExample is a simple command-line interface (CLI) shopping application developed in .NET 8. This project is designed to demonstrate and compare the use of Entity Framework Core (EF Core) ORM versus plain SQL queries when interacting with a SQLite database. By implementing the same functionalities using both approaches, this project provides insights into the benefits and drawbacks of each method.

Project Structure

The project includes two main implementations: one using Entity Framework Core and the other using plain SQL queries. Both implementations adhere to the following interface:

public interface IDataService
{
    Task InsertPredefinedData();
    Task<List<User>> GetAllUsers();
    Task<List<Product>> GetAllProducts();
    Task CreateOrder(int userId, List<int> productIds);
    Task<List<Order>> GetUserOrdersWithOrderDetails(int userId);
    Task<List<Order>> GetAllOrderWithOrderDetailsAndUser();
}

Features

  • InsertPredefinedData: Inserts predefined data into the database.
  • GetAllUsers: Retrieves a list of all users.
  • GetAllProducts: Retrieves a list of all products.
  • CreateOrder: Creates an order for a specified user with a list of product IDs.
  • GetUserOrdersWithOrderDetails: Retrieves orders with detailed order information for a specified user.
  • GetAllOrderWithOrderDetailsAndUser: Retrieves all orders along with detailed order information and associated user data.

Prerequisites

  • .NET 8 SDK
  • SQLite

Setup and Running the Project Locally

  1. Clone the Repository

    git clone https://github.com/moeen/IntroToEFExample.git
    cd IntroToEFExample
  2. Build the Project

    dotnet build
  3. Run the Project

    dotnet run --project ./src/IntroToEFExample
  4. Select Implementation During execution, you will be prompted to choose between the EF Core implementation and the Plain SQL implementation.

Using the Application

Upon running the application, you will have access to a menu-driven interface where you can:

  • Insert predefined data.
  • List all users.
  • List all products.
  • Create an order.
  • List user orders with details.
  • List all orders with details and user information.

Additional Resources

For more details on Entity Framework and a deeper understanding of the concepts demonstrated in this project, please refer to the presentation slides used in the project:

Introduction to Entity Framework

Summary of the Presentation:

  • Entity Framework Overview: Introduction to ORM and EF Core.
  • Features of Entity Framework: Benefits and key features.
  • CRUD Operations: Examples of Create, Read, Update, and Delete operations using EF Core.
  • Comparison: Pros and cons of using an ORM versus direct SQL queries.
  • Practical Example: Demonstration using EF Core vs. plain queries.

introtoefexample's People

Contributors

moeen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.