MVC应用程序如何插入到DB中

时间:2015-03-13 04:39:56

标签: asp.net-mvc linq linq-to-sql

我在Controller中尝试了什么

private void AddNewImpIdeas()
{
    using (WCMTablesDataContext myDb = new WCMTablesDataContext())
    {
        ImprovementIdeasTracking ImprvInfo = new ImprovementIdeasTracking();

        ImprvInfo.Submitted = //the c code is not populating for submitted

        myDb.ImprovementIdeasTrackings.InsertOnSubmit(ImprvInfo);
        myDb.SubmitChanges();
        var ideas = from i in myDb.ImprovementIdeasTrackings select i;

我已将我的控制器文件粘贴到https://jsfiddle.net/c4ft8pjt/

1 个答案:

答案 0 :(得分:1)

 using (WCMTablesDataContext myDb = new WCMTablesDataContext())
    {
        ImprovementIdeasTracking ImprvInfo = new ImprovementIdeasTracking();

        ImprvInfo.Submitted = //the c code is not populating for submitted

        myDb.ImprovementIdeasTrackings.Add(ImprvInfo);
        myDb.SaveChanges();
        var ideas = from i in myDb.ImprovementIdeasTrackings select i;