【发布时间】:2012-06-19 20:54:13
【问题描述】:
我的数据库中有一个这样的表:
[id] [uniqueidentifier] NOT NULL,
[user_id] [uniqueidentifier] NOT NULL,
[download_type] [nvarchar](50) NOT NULL,
[download_id] [nvarchar](50) NOT NULL,
[download_date] [datetime] NOT NULL,
[user_ip_address] [nvarchar](20) NOT NULL,
id 被定义为主键。
我想在这个表中插入一条新记录。这是我无法开始工作的代码。
CustomerPortalEntities_Customer_Downloads dbcd = new CustomerPortalEntities_Customer_Downloads();
public ActionResult Download(string id)
{
var collection = new FormCollection();
collection.Add("user_id", Membership.GetUser().ProviderUserKey.ToString());
collection.Add("download_type", "Car");
collection.Add("download_id", id);
collection.Add("download_date", DateTime.Now.ToString());
collection.Add("user_ip_address", Request.ServerVariables["REMOTE_ADDR"]);
dbcd.AddToCustomer_Downloads(collection);
return Redirect("../../Content/files/" + id + ".EXE");
}
我得到的错误是 dbcd.AddToCustomer_Downloads(collection);
“CustomerPortalMVC.Models.CustomerPortalEntities_Customer_Downloads.AddToCustomer_Downloads(CustomerPortalMVC.Models.Customer_Downloads)”的最佳重载方法匹配 有一些无效的参数
参数“1”:无法从“System.Web.Mvc.FormCollection”转换为 'CustomerPortalMVC.Models.Customer_Downloads'
我需要进行哪些更改才能完成这项工作?
【问题讨论】:
标签: c# entity-framework asp.net-mvc-2