Click here to Skip to main content
15,895,836 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am using web service to fetch data from database using entity frame work and stored procedure.
Is it compulsory to bind this data with the model?
Posted

Chances are that if you're using Entity framework, you view (what ever it is, HTML web page or a Web Form) is already bound to your model... Entity framework uses a model to fetch data or to perform different CRUD operations. The list that you're watching; after querying the database is a result of the CRUD operation of Entity framework over model.

If you're going to use Entity framework for all of your operations, create, read, update and delete, then yes your model will be bound to your application's views for operations. It is up to you, how you define "model binding". By the way, there is nothing compulsory in programming. It is just a requirement of your programming model; paradigm. So, which so ever pattern you're using, read about it and you will find the answer about it more explicitly there.
 
Share this answer
 
C#
[WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public string GetSubCategories(int CategoryId)
        {

            DataTable dt = BusinessLayer.ycfoCore.populateSubCategories(CategoryId.ToString());

            var query = from row in dt.AsEnumerable()
                        select new
                        {
                            Id = row["Id"].ToString(),
                            Name = (string)row["Name"]
                        };

            JObject o = JObject.FromObject(new
            {
                Table = query
            });

            return o.ToString();
        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900