這可能是我花了數小時解決很長時間的最大浪費時間問題。值不能爲空。參數名稱:來源
var db = new hublisherEntities();
establishment_brands est = new establishment_brands();
est.brand_id = 1;
est.establishment_id = 1;
est.price = collection["price"];
est.size = collection["size"];
db.establishment_brands.Add(est);
db.SaveChanges();
這給我的
值的誤差不能爲空。參數名:源
[ArgumentNullException的堆棧跟蹤:值不能爲空。參數名稱:源] System.Linq.Enumerable.Any(IEnumerable的
1 source, Func
2謂詞) 4083335 System.Data.Entity.Internal.InternalContext.WrapUpdateException(UpdateException updateException)87
System.Data.Entity.Internal。 InternalContext.SaveChanges()193個
System.Data.Entity.Internal.LazyInternalContext.SaveChanges()+33
System.Data.Entity.DbContext.SaveChanges()+20 ......
我只想添加一個實體到表中。 ORM是EF。
是不是例外信息說明?有些內容不能爲null。你的數據庫模式是什麼? – 2013-04-29 14:27:04
您可能需要查看此問題及其答案:http://stackoverflow.com/questions/3244336/using-linq-to-find-item-in-a-list-but-get-value-cannot-be -null-parameter-name – 2013-04-29 14:29:08
可能其中一個collectin中的條目具有空值:est.price = collection [「price」]; est.size = collection [「size」]; – MikeTWebb 2013-04-29 14:29:17