我成功地从数据库表中读取了我的记录,并且我将信息放在类型为ClaimComment
的List中(用于映射的类),因为我需要将信息放在新的数据库表中。
using (var dbContext = new OldDbContextEntities())
{
var claimComments = dbContext.R_ClaimHistory.ToList();
var newDbContextClaimCommentsToSend = new List<ClaimComment>();
foreach (var claimComment in claimComments)
{
var claimCommentToMigrate = new ClaimComment()
{
ClaimId = (int)claimComment.IdClaim,
Comment = claimComment.HistClaimDescription,
DateCreated = claimComment.DateCreated,
UserCreated = (int)claimComment.IdUserCreated
};
newDbContextClaimCommentsToSend.Add(claimCommentToMigrate);
}
// continues below...
我需要使用Web Api将信息放入database2表中。 我是这样开始的:
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("http://localhost:54957/api/EntityMigration");
var response = client.PostAsync("api/claimComment", newDbContextClaimCommentsToSend);
}
但我收到错误:
错误CS1503参数2:无法转换 &#39; System.Collections.Generic.List&#39; 到&#39; System.Net.Http.HttpContent&#39;