2011-11-15 5 views

答えて

2

は、 "名前" に一意のインデックスを作成し

for example, in shell: db.MyCollection.ensureIndex({"Name":1}, {unique = true}) 

が追加InsertOptions

var options = new MongoInsertOptions (myCollection) { CheckElementNames = true, Flags = InsertFlags.ContinueOnError, SafeMode = SafeMode.True}; 

var res = myCollection.InsertBatch(value.Split(',').Where(o => !string.IsNullOrEmpty(o)).Select(o => new Client { Name = o.Trim() }), options); 
関連する問題