我在wcf服务中有这样的方法
public string PostAllSurveList(List<Survey> surveyList)
{
var surveyDbList = ConstructDbServeyList(surveyList);
foreach (var survey in surveyDbList)
{
_db.surveys.Add(survey);
}
_db.SaveChanges();
return "Successfully Saved";
}
Run Code Online (Sandbox Code Playgroud)
当我通过以下方式在C#中调用此方法时,它工作正常
var surveys = new Survey[]{new Survey{ Id = 1, ConsumerName = "atish"},};
string reply = client.PostAllSurveList(surveys);
Run Code Online (Sandbox Code Playgroud)
但不是以下列方式工作
var surveys = new List<Survey>{ new Survey { Id = 1, ConsumerName = "atish"}};
string reply = client.PostAllSurveList(surveys);
Run Code Online (Sandbox Code Playgroud)
得到编译时错误.
我的问题是为什么会这样.
| 归档时间: |
|
| 查看次数: |
69 次 |
| 最近记录: |