0

I have already made a SQL string for innerjoin the 2 tables I want

This is from DataAceess layer

  public void showTable()
        {
            string queryString = " Select Product.name, Product.price,ShoppingCart.Count " + "From Product" +
                 " INNER JOIN ShoppingCart On Product.ID = ShoppingCart.ProductId";

            using (SqlConnection con = new SqlConnection(_connectionString))
            using (SqlCommand readCommand = new SqlCommand(queryString, con))
            {
                con.Open();
                SqlDataReader shoppingCartReader = readCommand.ExecuteReader();
               

            }
            

        }

This is from Controller

  public async Task<IActionResult> Index()

        {
            /*
            shoppingcart = new ShoppingCartViewModel()
            {
                ListCart = dataacc.getAll()
            }; */
            var showTable = dataacc.showTable();

            return View();
        }

This is from .cshtml

@{
    ViewData["Title"] = "Index";
}

<h1>Order information</h1>

<hr />



<div>

    <div class="col-md-2"> 
    <form asp-action="Index">
        <div asp-validation-summary="ModelOnly" class="text-danger"></div>
        <div class="form-group">
            <label asp-for="Customer.FirstName" class="control-label"></label>
            <input asp-for="Customer.FirstName" class="form-control" />
            <span asp-validation-for="ID" class="text-danger"></span>
        </div>
        <div class="form-group">
            <label asp-for="Customer.LastName" class="control-label"></label>
            <input asp-for="Customer.LastName" class="form-control" />
            <span asp-validation-for="customerId" class="text-danger"></span>
        </div>
        <div class="form-group">
            <label asp-for="orderDate" class="control-label"></label>
            <input asp-for="orderDate" class="form-control" />
            <span asp-validation-for="orderDate" class="text-danger"></span>
        </div>

    </form>
    </div>

    <div class="col-md-8">
        
        <table class="table">
        <thead>
            <tr>
                <th>Selected Amount</th>
                <th>Menu</th>
                <th>Price</th>
                <th>Subtotal</th>
            </tr>
        </thead>

I don't know what to do next, i can't convert my query to a list. Hopes someone know this Thank you for helping :D

I tried to make queries and convert to list using var but it didn't work

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.