ASP.NET MVC個人学習ノートの提出フォーム

2220 ワード

//     action  ,     controller  
@using (Html.BeginForm("CreateItem", "Knoledge"))
{   
    <fieldset>
        <legend>KnolegeModels</legend>
        <div class="editor-label">
              :<input name="m_strTitle" class="createKnoledge" />
              :<input name="m_strUserId" class="createKnoledge"  />
              :<input class="easyui-datebox" name="m_dateUploadTime" data-options="required:true,showSeconds:false"
                value="new Date();" style="width: 150px" />
            @Html.ActionLink("Back to List", "Index")
            <input type="submit" value="Create" />
        </div>
        <div class="editor-label">
              :
        </div>
        <div class="editor-label">
            <textarea name="m_strDesc" class="KnoledgeDesc"></textarea>
        </div>
    </fieldset>
}
  //      view input name
  public ActionResult CreateItem(string m_strUserId, string m_strTitle, string m_strDesc, string m_dateUploadTime)
        {
            //     ,       ,    。
            Dictionary<string, string> _dictParam = new Dictionary<string, string>();
            _dictParam.Add("Id", Guid.NewGuid().ToString());
            _dictParam.Add("m_strUserId", m_strUserId);
            _dictParam.Add("m_strTitle", m_strTitle);
            _dictParam.Add("m_strDesc", m_strDesc);
            _dictParam.Add("m_dateUploadTime", m_dateUploadTime);
            string _strSql = "insert into knoledge(Id,m_strUserId,m_strTitle,m_strDesc,m_dateUploadTime,m_strhot) values(:Id,:m_strUserId,:m_strTitle,:m_strDesc,to_date(:m_dateUploadTime,'yyyy-MM-dd'),0)";
            int iResult = CommonFunction.OraExecuteNonQuery(_strSql, _dictParam);
            //     view
            return View("Create");
        }

entity frameworkにあまり慣れていないのは、原生のsqlがもっとコントロールできると感じていることと、EFが通用しないと感じていることです.(実はよくわからないんですよー_-|||--||)