在cshtml中创建新闻源

时间:2014-07-06 19:03:39

标签: mysql asp.net-mvc asp.net-mvc-4 razor

我在数据库中有以下内容

status table - status_id, status_body, status_date
student table - student_id, student_username, student_firstname, student_lastname
follow table - followId, follow_followerid, follow_followingid`

现在,我想显示用户(比如用户A)当前跟随的用户状态以及他(用户A)自己的状态更新。

我怎样才能在cshtml中做到这一点? SQL查询是必要的。 有什么帮助吗?

1 个答案:

答案 0 :(得分:0)

您无法在cshtml文件中放置SQL查询。必须发生一系列事件。您只使用数据库查询的结果来提供cshtml。您还需要一些服务器端代码来提供cshtml,例如使用MVC的c#。您需要一种方法来访问您的数据库,例如对象关系映射器,例如Entity Framework。如果你想做这项工作,你有很多步骤。

相关问题