开发者

How to display Data in View through LINQ?

开发者 https://www.devze.com 2023-02-16 19:33 出处:网络
I am NEW in MVC3 so bear with me here. I went through this link to start learning MVC3: ASP.NET MVC3 Tutorial

I am NEW in MVC3 so bear with me here. I went through this link to start learning MVC3: ASP.NET MVC3 Tutorial

I created everything alright. Now I want to go one step ahead with LINQ. In my UserModel class (as in this example) I created this code in another class inside this called User where there is implementation of Adding, Deleting, Editing.

 DataDataContext dt = new DataDataContext();
            var q = from a in dt.GetTable<Entity>()
                    select a;

'Data' is the DBMLconnection for LINQ. And Entity is the table.

开发者_运维百科

Now how should I select selective columns in the table (Entity) to my view? Any answers or links will be appreciated! Thank you :)


I think you should start with:

http://www.asp.net/mvc/tutorials/mvc-music-store-part-1

In your code. Pass first the entity to your linq.

Then after that in your Controller right click return view(q) and then click add view and select details.

Regards

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号