A community member has associated this post with a similar question:
Image in Adaptive card inside Action.ShowCard button in showing undefined

Only moderators can edit this content.

MVC and knockout database stored Procedures

Nalajala Ganesh 1 Reputation point
2022-02-15T06:18:05.303+00:00

Hi All,
how to connect stored procedures with mvc application using Knockout

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,367 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,157 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,252 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,234 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Zhi Lv - MSFT 32,011 Reputation points Microsoft Vendor
    2022-02-15T08:46:01.037+00:00

    Hi @Nalajala Ganesh ,

    Whether your MVC application is an Asp.net core MVC application or a .Net Framework MVC application? About the difference between .NET and .NET Framework, refer to .NET vs. .NET Framework for server apps.

    Besides whether you are using Entity Framework Core or Entity Framework to access the database?

    Here are some relate articles about working with Stored Procedure in Entity Framework, you can refer them:

    Working with Stored Procedure in Entity Framework Core

    CUD Operations using Stored Procedures in Entity Framework 6 Code-First Approach

    Then, you can create a MVC controller or API controller to access the database via the stored procedures, then use knockoutjs to access the controller and get the data. Finally, in the view page, use knockoutjs to bind model and render data.

    Here are some articles about using Knockout.js, you can refer them:

    Knockout.js MVVM Framework (asp.net core)

    ASP.NET MVC With Knockout.Js


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Dillion

    1 person found this answer helpful.
    0 comments No comments
  2. Bruce (SqlWork.com) 55,601 Reputation points
    2022-02-15T19:02:24.183+00:00

    .net MVC is framework for building server html form based application using a modified variant of the well known MVC pattern.

    you define a render and post back model (in most examples they are the same)
    you define a action that receives model (form post), processes it and sets a modified model to the view
    you define a view to render the model as html.

    MVC routing map a request (form post or get) to an action and bind the request data to the action parameters. The action process the request data, creates a view model and calls a view. The view renders the html. repeat

    MVC can also be be used to implement webapi request handling. rather than render html, the request return data typically in xml or json format.

    an alternative is to build the application in javascript, and make ajax calls to the server (typically webapi in .net). knockout.js is a binding framework to implement the MVC pattern in javascript. it supports two way binding to html elements.

    in knockout, there is a true observable model defined by MVC pattern. updates to the model, trigger events that redisplay the view (knockout does this via binding). view (dom events) update the model. again knockout supports binding element events to the model. in the model you define event handlers that are called to process model changes. these model event handlers will use ajax to update the server with model changes.

    one disadvantage of knockout is it is only the binding library and model, it does not have a view engine, you must pick one, or use simple dom elements. If you pick a view library like kendo ui, it has its own two-way binding package and knockout is not required (knockout support is mostly to kendo-ui to an existing knockout application).

    there are two types of javascript applications. SPA (Single Page App), where the javascript code intercepts navigation, and there is really only one website page. MPA (Multiple page applications), where each website page is a separate application. knockout supports SPA if you add a navigation library.

    for building javascript applications, there are more full featured frameworks, and knockout is not typically selected for new projects. as you are just starting out, you might be better served picking a more opinionated framework. the most popular javascript frameworks are:

    react.js
    vue.js (easiest for MPA)
    angular

    note: there is also blazor SPA which you code in C#

    1 person found this answer helpful.
    0 comments No comments