내 저장소 당신을 위해 많은에 조금있을 수 있습니다, 짧은 대답 대신
public async Task<IEnumerable<T>> GetDocumentsAsync<T>(Expression<Func<T, bool>> predicate, int maxReturnedDocuments = -1,
bool enableCrossPartitionQuery = true, int maxDegreeOfParallellism = -1, int maxBufferedItemCount = -1)
{
//MaxDegreeofParallelism default = 0, add -1 to let SDK handle it instead of a fixed 1 network connection
var feedOptions = new FeedOptions
{
MaxItemCount = maxReturnedDocuments,
EnableCrossPartitionQuery = enableCrossPartitionQuery,
MaxDegreeOfParallelism = maxDegreeOfParallellism,
MaxBufferedItemCount = maxBufferedItemCount
};
IDocumentQuery<T> query = client.CreateDocumentQuery<T>(
UriFactory.CreateDocumentCollectionUri(_databaseName, _collectionName), feedOptions)
.Where(predicate)
.AsDocumentQuery();
List<T> results = new List<T>();
while (query.HasMoreResults)
{
var res = await query.ExecuteNextAsync<T>();
results.AddRange(res);
}
return results;
}
ToList()의) .AsDocumentQuery를 (반환 할 수있다
은이 같은 상기 방법을 호출 할 수 VAR의 ecsterConfigs의이 repoBO.GetDocumentsAsync = (c => c.ValidTo == 널 & & c.Type == 타입) 기다리고;
그리고 나서 문서의 업데이트를 "할"때 문서를 업데이트 할 때 변경 될 _Etag를 추적하기 위해 래퍼가 있습니다.
public class DocumentWrapper<DocumentType>
{
public DocumentWrapper(Document document)
{
Value = (DocumentType)(dynamic)document;
ETag = document.ETag;
TimeStamp = document.Timestamp;
}
public DocumentType Value { get; set; }
public string ETag { get; set; }
public DateTime TimeStamp { get; set; }
}
오브젝트의 유형을 설정하는 아이디어를 확장합니다. 수동으로하기보다는 기본 클래스를 상속하는 객체의 이름을 제공하는 기본 클래스 (위의'Entity')에서'public string Type => this.GetType(). Name;'을 할 수 있습니다 ('RuleSetGroup '및'OtherType' 위) – Dezzamondo