C# 将带有对象的文件发送到webapi

C# 将带有对象的文件发送到webapi,c#,sql,web-services,asp.net-web-api,C#,Sql,Web Services,Asp.net Web Api,我的项目有问题。 我在mssql中有一个表,它的picaddress为nvarchar,id也是唯一的。 要创建新对象,我必须将名称发送到服务器以创建新id,然后将图像发送到服务器,然后保存picaddress,但我喜欢同时发送表和图像的对象 我能做什么 BitmapImage s1 = new BitmapImage(); s1.BeginInit(); s1.UriSource = new Uri(openfiledialog.FileName); s1.EndInit(); image.S

我的项目有问题。 我在mssql中有一个表,它的picaddress为nvarchar,id也是唯一的。 要创建新对象,我必须将名称发送到服务器以创建新id,然后将图像发送到服务器,然后保存picaddress,但我喜欢同时发送表和图像的对象

我能做什么

BitmapImage s1 = new BitmapImage();
s1.BeginInit();
s1.UriSource = new Uri(openfiledialog.FileName);
s1.EndInit();
image.Source = s1;
var requestContent = new MultipartFormDataContent();
ByteArrayContent fileContent = new ByteArrayContent(System.IO.File.ReadAllBytes(openfiledialog.FileName));
fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = openfiledialog.FileName };
requestContent.Add(fileContent, openfiledialog.FileName, openfiledialog.FileName);
HttpClient cli = new HttpClient();
cli.PostAsync(Ntaban.Api.API_server.Host+ "api/managment/Insert_Product", requestContent);

这是我的对象宫内节育器,图像是s1。

为什么不将其全部封装在一个类中,然后传递它呢?图像可以使用哪个属性?