填坑之路 MVC5 新闻发布系统

读书不认真,什么都不知道,强行学MVC=》留言板是一切开始


做一个新闻发布系统

我想要的效果是

 一:          新闻发布系统 3个数据表:  新闻数据,新闻类型,评论表

                                                    1、列表页   (所有)新闻类型+新闻标题 要输出,要遍历,要攻克

                                                     2、.详情页   (单个,需Id)只要输出一个

                                                     3、新闻评论列表  (单个,需Id)+评论


Model:

    public class N_New
    {
        [Key]
        public int ID { set; get; }
        public int CategoryId { get; set; }
        public string NewsTitle { get; set; }
        public string NewsContent { get; set; }
        public DateTime CreateTime { get; set; }
    }
    public class N_Category
    {
        [Key]
        public int CategoryId { get; set; }
        public int CategoryPid { get; set; }
        public string CategoryName { get; set; }
    }
    public class N_Comment
    {
        [Key]
        public int CommentId { get; set; }
        public string CommentContent { get; set; }
        public DateTime CreateTime { get; set; }
        public int NewsId { get; set; }
        public int UserId { get; set; }
    }


二: 这东西解决如果是以前就是:

            GET:Id    =>   

                    详情页  select N_New.*, N_Category.CategoryName  from N_New,N_Category  where N_New.ID=Id andN_Category.CategoryId=N_New.CategoryId 

                     列表页   select N_New.*, N_Category.CategoryName  from N_New,N_Category   where N_Category.CategoryId=N_New.CategoryId 

  SQL查询后:

Id        CategoryId   NewsTitel  NewsContent   CreateTime          CategoryName          

1	1	2	3	2015-01-01 00:00:00.000	成人教育
2	2	test	我爱你	2015-01-01 00:00:00.000	职称考试
3	1	test	test	2015-01-01 00:00:00.000	成人教育
4	4	4	4	2015-01-01 00:00:00.000	教师证培训
5	8	8	8	2015-01-01 00:00:00.000	电子商务证

三:思路出来  

                 1.将sql改成 Linq

                        基础:Lambda表达式详细总结   http://blog.csdn.net/sf1520398083/article/details/49048427

                            详情页:

                           列表页:

                2. 模型类传给视图(模型传值、Json传值)

                               ①    模型传值  http://blog.csdn.net/sf1520398083/article/details/49048423

    public class New_Cate {
        public string New_idname { set; get; }
        public N_New N_new { set; get;  }
    }

Controller:

View:


        

                       ②Json传值    http://blog.csdn.net/sf1520398083/article/details/49053037

 今天一个们给我建议,强行学LINq 不如把 ADO.NET基础打好,自己封装类

我瞬间知道自己做了很多无用功

开始 三层模式写MVC新闻


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值