in Microsoft.Azure.Cosmos/src/DocumentClient.cs [6569:6652]
internal IStoreModel GetStoreProxy(DocumentServiceRequest request)
{
// If a request is configured to always use Gateway mode(in some cases when targeting .NET Core)
// we return the Gateway store model
if (request.UseGatewayMode)
{
return this.GatewayStoreModel;
}
ResourceType resourceType = request.ResourceType;
OperationType operationType = request.OperationType;
if (resourceType == ResourceType.Offer ||
(resourceType.IsScript() && operationType != OperationType.ExecuteJavaScript) ||
resourceType == ResourceType.PartitionKeyRange ||
resourceType == ResourceType.Snapshot ||
resourceType == ResourceType.ClientEncryptionKey ||
(resourceType == ResourceType.PartitionKey && operationType == OperationType.Delete))
{
return this.GatewayStoreModel;
}
if (this.isThinClientEnabled
&& operationType == OperationType.Read
&& resourceType == ResourceType.Database)
{
return this.GatewayStoreModel;
}
if (operationType == OperationType.Create
|| operationType == OperationType.Upsert)
{
if (resourceType == ResourceType.Database ||
resourceType == ResourceType.User ||
resourceType == ResourceType.Collection ||
resourceType == ResourceType.Permission)
{
return this.GatewayStoreModel;
}
else
{
return this.StoreModel;
}
}
else if (operationType == OperationType.Delete)
{
if (resourceType == ResourceType.Database ||
resourceType == ResourceType.User ||
resourceType == ResourceType.Collection)
{
return this.GatewayStoreModel;
}
else
{
return this.StoreModel;
}
}
else if ((operationType == OperationType.Replace) || (operationType == OperationType.CollectionTruncate))
{
if (resourceType == ResourceType.Collection)
{
return this.GatewayStoreModel;
}
else
{
return this.StoreModel;
}
}
else if (operationType == OperationType.Read)
{
if (resourceType == ResourceType.Collection)
{
return this.GatewayStoreModel;
}
else
{
return this.StoreModel;
}
}
else
{
return this.StoreModel;
}
}