2017-02-03 10 views
7

Azure DocumentDB'de yeniyim ve bunu denerken hemen bir soruna girdim. aşağıdaki gibi (kısmi)ResourceType Belge beklenmedik bir durumdur UpsertDocumentAsync()

ResourceType Document is unexpected.

ActivityId: 29619975-e55a-4f31-a3d1-73d180ba3932

Benim depo kodudur:

public interface IEntity 
{ 
    string Id { get; set; } 
    DateTime DbCreatedAt { get; set; } 
    DateTime DbLastUpdatedAt { get; set; } 
} 

public class Repository<T>: IRepository<T> where T: class, IEntity 
{ 
    private DocumentClient _documentClient; 
    private string _databaseName; 
    private string _collectionName; 

    // .... 
    // .... 

    public Task SaveAsync(T entity) 
    { 
     var documentUri = UriFactory.CreateDocumentUri(_databaseName, _collectionName, entity.Id); 
     return _documentClient.UpsertDocumentAsync(documentUri, entity); 
    } 
} 

Bu ilk defa birşey hiç yazılmıştır ilk olarak boş koleksiyonunda kaydetmek günü, aşağıdaki hatayı alıyorum bu veritabanı/koleksiyon. Yanlış bir şey mi yapıyorum?

cevap

14

UpsertDocumentAsync, Belge bağlantısı yerine DocumentCollection bağlantısını almalıdır.

+4

Teşekkürler, buydu. DocumentDB API zaman zaman bana biraz belirsiz görünüyor. – Carvellis