當我運行下面的代碼:Simple.Data插入對象 - 列表初始化必須包含至少一個初始化
var db = Database.Open();
var contact = new Contact() {FirstName = "Mark", LastName = "Rendle"} ;
db.Contacts.Insert(contact);
我得到一個錯誤:
列表初始化必須至少包含一個初始化
堆棧跟蹤: 在System.Linq.Expressions.Expression.ListInit(NewExpression newExpression,IEnumerable的1 initializers) at Simple.Data.Extensions.ObjectEx.MakeToDictionaryFunc(Type type) at System.Collections.Concurrent.ConcurrentDictionary
2.GetOrAdd(TKEY的關鍵,Func鍵2 valueFactory) at Simple.Data.Extensions.ObjectEx.ObjectToDictionary(Object obj) at Simple.Data.Commands.InsertCommand.InsertEntity(Object entity, DataStrategy dataStrategy, String tableName, ErrorCallback onError, Boolean resultRequired) at Simple.Data.Commands.InsertCommand.DoInsert(InvokeMemberBinder binder, Object[] args, DataStrategy dataStrategy, String tableName) at Simple.Data.Commands.InsertCommand.Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, Object[] args) at Simple.Data.DynamicTable.TryInvokeMember(InvokeMemberBinder binder, Object[] args, Object& result) at Simple.Data.ObjectReference.TryInvokeMember(InvokeMemberBinder binder, Object[] args, Object& result) at CallSite.Target(Closure , CallSite , Object , Object) at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid2[T0,T1](CallSite site, T0 arg0, T1 arg1) at ProjectXBaseDataImporter.DataSaver.PersistContacts(IEnumerable
1 contactsx)在C:\代碼\ XXX \ ProjectXBaseDataImporter \ ProjectXBaseDataImporter \ CSVImporter.cs:在C線54 在ProjectXBaseDataImporter.DataImporter.Import [T](字符串文件路徑):\代碼\ XXX \ ProjectXBaseDataImporter \ ProjectXBaseDataImporter \ CSVImporter。 CS:\代碼\ XXX \ ProjectXBaseDataImporter \ ProjectXBaseDataImporter \ CSVImporter_Test.cs:在我的部分線32
堆棧跟蹤的任何機會呢? – 2013-03-10 23:03:49
請找上面 – youeee 2013-03-10 23:22:49