本文整理汇总了C#中Amazon.DynamoDBv2.Model.GetItemRequest类的典型用法代码示例。如果您正苦于以下问题:C# GetItemRequest类的具体用法?C# GetItemRequest怎么用?C# GetItemRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GetItemRequest类属于Amazon.DynamoDBv2.Model命名空间,在下文中一共展示了GetItemRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetItem
public int GetItem(string dbKey, string dbKeyValue, string table, out GetItemResponse paramResponse)
{
GetItemRequest request = new GetItemRequest();
request.TableName = table; // set the table name for DynamoDB
request.Key = new Dictionary<string, AttributeValue>() { { dbKey, new AttributeValue { S = dbKeyValue } } };
int response = (int)DBEnum.DBResponseCodes.DEFAULT_VALUE;
try
{
paramResponse = this.client.GetItem(request); // value set to NOT null
//Check to see if entry exist
if (0 == paramResponse.Item.Count) // Entry does not exist
{
response = (int)DBEnum.DBResponseCodes.DOES_NOT_EXIST;
}
else // Entry exists
{
response = (int)DBEnum.DBResponseCodes.SUCCESS;
}
}
catch
{
response = (int)DBEnum.DBResponseCodes.DYNAMODB_EXCEPTION; // set reponse to DB Exception flag
paramResponse = null; // set to null on Error
}
return response;
}
示例2: GetData1
// Get TestID
public static void GetData1(int Id)
{
var Req = new Amazon.DynamoDBv2.Model.GetItemRequest
{
TableName = "TestID",
Key = new Dictionary<string, Amazon.DynamoDBv2.Model.AttributeValue>() { {"Id",new Amazon.DynamoDBv2.Model.AttributeValue{N=Id.ToString()}}}
};
var Rsp = client.GetItem(Req);
PrintItem(Rsp.GetItemResult.Item);
Console.ReadLine();
}
示例3: GetData
public static void GetData(string UID, string tableName)
{
Table testDB = Table.LoadTable(client, tableName);
var request = new Amazon.DynamoDBv2.Model.GetItemRequest
{
TableName = tableName,
Key = new Dictionary<string,Amazon.DynamoDBv2.Model.AttributeValue>()
{{"UID",new Amazon.DynamoDBv2.Model.AttributeValue{S=UID}}}
};
var response = client.GetItem(request);
var result = response.GetItemResult;
Console.WriteLine("Units");
Console.WriteLine(response.GetItemResult.ConsumedCapacity.CapacityUnits);
Console.WriteLine("Data");
Console.WriteLine(response.GetItemResult.Item.Count);
Console.ReadLine();
}
示例4: CheckUserIsExist
public bool CheckUserIsExist(string userID)
{
var config = new AmazonDynamoDBConfig();
GetItemResponse response;
config.ServiceURL = System.Configuration.ConfigurationManager.AppSettings["ServiceURL"];
client = new AmazonDynamoDBClient(config);
bool retval = false;
try
{
GetItemRequest request = new GetItemRequest
{
TableName = "User",
Key = new Dictionary<string, AttributeValue>() { { "UserID", new AttributeValue { S = userID } } },
ReturnConsumedCapacity = "TOTAL"
};
response = client.GetItem(request);
retval = response.Item.Count > 0;
}
catch (AmazonDynamoDBException e) { Console.WriteLine(e.Message); }
catch (AmazonServiceException e) { Console.WriteLine(e.Message); }
catch (Exception e) { Console.WriteLine(e.Message); }
return retval;
}
示例5: BeginGetItem
/// <summary>
/// Initiates the asynchronous execution of the GetItem operation.
/// <seealso cref="Amazon.DynamoDBv2.AmazonDynamoDB.GetItem"/>
/// </summary>
///
/// <param name="getItemRequest">Container for the necessary parameters to execute the GetItem operation on AmazonDynamoDBv2.</param>
/// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
/// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.</param>
///
/// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetItem
/// operation.</returns>
public IAsyncResult BeginGetItem(GetItemRequest getItemRequest, AsyncCallback callback, object state)
{
return invokeGetItem(getItemRequest, callback, state, false);
}
示例6: GetItem
/// <summary>
/// The <i>GetItem</i> operation returns a set of attributes for the item with the given
/// primary key. If there is no matching item, <i>GetItem</i> does not return any data.
///
///
/// <para>
/// <i>GetItem</i> provides an eventually consistent read by default. If your application
/// requires a strongly consistent read, set <i>ConsistentRead</i> to <code>true</code>.
/// Although a strongly consistent read might take more time than an eventually consistent
/// read, it always returns the last updated value.
/// </para>
/// </summary>
/// <param name="tableName">The name of the table containing the requested item.</param>
/// <param name="key">A map of attribute names to <i>AttributeValue</i> objects, representing the primary key of the item to retrieve. For the primary key, you must provide all of the attributes. For example, with a hash type primary key, you only need to provide the hash attribute. For a hash-and-range type primary key, you must provide both the hash attribute and the range attribute.</param>
/// <param name="consistentRead">A value that if set to <code>true</code>, then the operation uses strongly consistent reads; otherwise, eventually consistent reads are used.</param>
///
/// <returns>The response from the GetItem service method, as returned by DynamoDB.</returns>
/// <exception cref="Amazon.DynamoDBv2.Model.InternalServerErrorException">
/// An error occurred on the server side.
/// </exception>
/// <exception cref="Amazon.DynamoDBv2.Model.ProvisionedThroughputExceededException">
/// The request rate is too high, or the request is too large, for the available throughput
/// to accommodate. The AWS SDKs automatically retry requests that receive this exception;
/// therefore, your request will eventually succeed, unless the request is too large or
/// your retry queue is too large to finish. Reduce the frequency of requests by using
/// the strategies listed in <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html#APIRetries">Error
/// Retries and Exponential Backoff</a> in the <i>Amazon DynamoDB Developer Guide</i>.
/// </exception>
/// <exception cref="Amazon.DynamoDBv2.Model.ResourceNotFoundException">
/// The operation tried to access a nonexistent table or index. The resource might not
/// be specified correctly, or its status might not be <code>ACTIVE</code>.
/// </exception>
public GetItemResponse GetItem(string tableName, Dictionary<string, AttributeValue> key, bool consistentRead)
{
var request = new GetItemRequest();
request.TableName = tableName;
request.Key = key;
request.ConsistentRead = consistentRead;
return GetItem(request);
}
示例7: invokeGetItem
IAsyncResult invokeGetItem(GetItemRequest getItemRequest, AsyncCallback callback, object state, bool synchronized)
{
IRequest irequest = new GetItemRequestMarshaller().Marshall(getItemRequest);
var unmarshaller = GetItemResponseUnmarshaller.GetInstance();
AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
Invoke(result);
return result;
}
示例8: GetItemAsync
/// <summary>
/// <para>The <i>GetItem</i> operation returns a set of attributes for the item with the given primary key. If there is no matching item,
/// <i>GetItem</i> does not return any data.</para> <para> <i>GetItem</i> provides an eventually consistent read by default. If your application
/// requires a strongly consistent read, set <i>ConsistentRead</i> to <c>true</c> . Although a strongly consistent read might take more time
/// than an eventually consistent read, it always returns the last updated value.</para>
/// </summary>
///
/// <param name="getItemRequest">Container for the necessary parameters to execute the GetItem service method on AmazonDynamoDBv2.</param>
///
/// <returns>The response from the GetItem service method, as returned by AmazonDynamoDBv2.</returns>
///
/// <exception cref="T:Amazon.DynamoDBv2.Model.ResourceNotFoundException" />
/// <exception cref="T:Amazon.DynamoDBv2.Model.ProvisionedThroughputExceededException" />
/// <exception cref="T:Amazon.DynamoDBv2.Model.InternalServerErrorException" />
/// <param name="cancellationToken">
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// </param>
public Task<GetItemResponse> GetItemAsync(GetItemRequest getItemRequest, CancellationToken cancellationToken = default(CancellationToken))
{
var marshaller = new GetItemRequestMarshaller();
var unmarshaller = GetItemResponseUnmarshaller.GetInstance();
return Invoke<IRequest, GetItemRequest, GetItemResponse>(getItemRequest, marshaller, unmarshaller, signer, cancellationToken);
}
示例9: GetItemAsync
/// <summary>
/// The <i>GetItem</i> operation returns a set of attributes for the item with the given
/// primary key. If there is no matching item, <i>GetItem</i> does not return any data.
///
///
/// <para>
/// <i>GetItem</i> provides an eventually consistent read by default. If your application
/// requires a strongly consistent read, set <i>ConsistentRead</i> to <code>true</code>.
/// Although a strongly consistent read might take more time than an eventually consistent
/// read, it always returns the last updated value.
/// </para>
/// </summary>
/// <param name="tableName">The name of the table containing the requested item.</param>
/// <param name="key">A map of attribute names to <i>AttributeValue</i> objects, representing the primary key of the item to retrieve. For the primary key, you must provide all of the attributes. For example, with a hash type primary key, you only need to provide the hash attribute. For a hash-and-range type primary key, you must provide both the hash attribute and the range attribute.</param>
/// <param name="consistentRead">Determines the read consistency model: If set to <code>true</code>, then the operation uses strongly consistent reads; otherwise, the operation uses eventually consistent reads.</param>
/// <param name="cancellationToken">
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// </param>
///
/// <returns>The response from the GetItem service method, as returned by DynamoDB.</returns>
/// <exception cref="Amazon.DynamoDBv2.Model.InternalServerErrorException">
/// An error occurred on the server side.
/// </exception>
/// <exception cref="Amazon.DynamoDBv2.Model.ProvisionedThroughputExceededException">
/// Your request rate is too high. The AWS SDKs for DynamoDB automatically retry requests
/// that receive this exception. Your request is eventually successful, unless your retry
/// queue is too large to finish. Reduce the frequency of requests and use exponential
/// backoff. For more information, go to <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html#APIRetries">Error
/// Retries and Exponential Backoff</a> in the <i>Amazon DynamoDB Developer Guide</i>.
/// </exception>
/// <exception cref="Amazon.DynamoDBv2.Model.ResourceNotFoundException">
/// The operation tried to access a nonexistent table or index. The resource might not
/// be specified correctly, or its status might not be <code>ACTIVE</code>.
/// </exception>
public Task<GetItemResponse> GetItemAsync(string tableName, Dictionary<string, AttributeValue> key, bool consistentRead, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
{
var request = new GetItemRequest();
request.TableName = tableName;
request.Key = key;
request.ConsistentRead = consistentRead;
return GetItemAsync(request, cancellationToken);
}
示例10: GetItem
internal GetItemResponse GetItem(GetItemRequest request)
{
var task = GetItemAsync(request);
try
{
return task.Result;
}
catch(AggregateException e)
{
ExceptionDispatchInfo.Capture(e.InnerException).Throw();
return null;
}
}
示例11: GetItemAsync
/// <summary>
/// Initiates the asynchronous execution of the GetItem operation.
/// <seealso cref="Amazon.DynamoDBv2.IAmazonDynamoDB"/>
/// </summary>
///
/// <param name="request">Container for the necessary parameters to execute the GetItem operation.</param>
/// <param name="cancellationToken">
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// </param>
/// <returns>The task object representing the asynchronous operation.</returns>
public Task<GetItemResponse> GetItemAsync(GetItemRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
{
var marshaller = new GetItemRequestMarshaller();
var unmarshaller = GetItemResponseUnmarshaller.Instance;
return InvokeAsync<GetItemRequest,GetItemResponse>(request, marshaller,
unmarshaller, cancellationToken);
}
示例12: GetItemAsync
/// <summary>
/// The <i>GetItem</i> operation returns a set of attributes for the item with the given
/// primary key. If there is no matching item, <i>GetItem</i> does not return any data.
///
///
/// <para>
/// <i>GetItem</i> provides an eventually consistent read by default. If your application
/// requires a strongly consistent read, set <i>ConsistentRead</i> to <code>true</code>.
/// Although a strongly consistent read might take more time than an eventually consistent
/// read, it always returns the last updated value.
/// </para>
/// </summary>
/// <param name="tableName">The name of the table containing the requested item.</param>
/// <param name="key">A map of attribute names to <i>AttributeValue</i> objects, representing the primary key of the item to retrieve. For the primary key, you must provide all of the attributes. For example, with a hash type primary key, you only need to provide the hash attribute. For a hash-and-range type primary key, you must provide both the hash attribute and the range attribute.</param>
/// <param name="consistentRead">A value that if set to <code>true</code>, then the operation uses strongly consistent reads; otherwise, eventually consistent reads are used.</param>
///
/// <returns>The response from the GetItem service method, as returned by DynamoDB.</returns>
/// <exception cref="Amazon.DynamoDBv2.Model.InternalServerErrorException">
/// An error occurred on the server side.
/// </exception>
/// <exception cref="Amazon.DynamoDBv2.Model.ProvisionedThroughputExceededException">
/// The request rate is too high, or the request is too large, for the available throughput
/// to accommodate. The AWS SDKs automatically retry requests that receive this exception;
/// therefore, your request will eventually succeed, unless the request is too large or
/// your retry queue is too large to finish. Reduce the frequency of requests by using
/// the strategies listed in <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html#APIRetries">Error
/// Retries and Exponential Backoff</a> in the <i>Amazon DynamoDB Developer Guide</i>.
/// </exception>
/// <exception cref="Amazon.DynamoDBv2.Model.ResourceNotFoundException">
/// The operation tried to access a nonexistent table or index. The resource might not
/// be specified correctly, or its status might not be <code>ACTIVE</code>.
/// </exception>
public void GetItemAsync(string tableName, Dictionary<string, AttributeValue> key, bool consistentRead, AmazonServiceCallback<GetItemRequest, GetItemResponse> callback, AsyncOptions options = null)
{
var request = new GetItemRequest();
request.TableName = tableName;
request.Key = key;
request.ConsistentRead = consistentRead;
GetItemAsync(request, callback, options);
}
示例13: GetUser
public Dictionary<string, object> GetUser(string userID)
{
Dictionary<string, object> retval = new Dictionary<string, object>();
GetItemResponse response;
var config = new AmazonDynamoDBConfig();
config.ServiceURL = System.Configuration.ConfigurationManager.AppSettings["ServiceURL"];
client = new AmazonDynamoDBClient(config);
try
{
GetItemRequest request = new GetItemRequest
{
TableName = "User",
Key = new Dictionary<string, AttributeValue>() { { "UserID", new AttributeValue { S = userID } } },
ReturnConsumedCapacity = "TOTAL"
};
response = client.GetItem(request);
retval.Add("UserID", response.Item["UserID"].S);
retval.Add("HeadshotURL", response.Item["HeadshotURL"].S);
retval.Add("IsPayUser", Convert.ToBoolean(response.Item["IsPayUser"].S));
retval.Add("UserName", response.Item["UserName"].S);
retval.Add("RegistDate", response.Item["RegistDate"].N);
retval.Add("LastLoginDate", response.Item["LastLoginDate"].N);
retval.Add("LastSyncDate", response.Item["LastSyncDate"].N);
}
catch (AmazonDynamoDBException e) { Console.WriteLine(e.Message); }
catch (AmazonServiceException e) { Console.WriteLine(e.Message); }
catch (Exception e) { Console.WriteLine(e.Message); }
return retval;
}
示例14: GetItem
/// <summary>
/// <para>The <i>GetItem</i> operation returns a set of attributes for the item with the given primary key. If there is no matching item,
/// <i>GetItem</i> does not return any data.</para> <para> <i>GetItem</i> provides an eventually consistent read by default. If your application
/// requires a strongly consistent read, set <i>ConsistentRead</i> to <c>true</c> . Although a strongly consistent read might take more time
/// than an eventually consistent read, it always returns the last updated value.</para>
/// </summary>
///
/// <param name="getItemRequest">Container for the necessary parameters to execute the GetItem service method on AmazonDynamoDBv2.</param>
///
/// <returns>The response from the GetItem service method, as returned by AmazonDynamoDBv2.</returns>
///
/// <exception cref="ResourceNotFoundException"/>
/// <exception cref="ProvisionedThroughputExceededException"/>
/// <exception cref="InternalServerErrorException"/>
public GetItemResponse GetItem(GetItemRequest getItemRequest)
{
IAsyncResult asyncResult = invokeGetItem(getItemRequest, null, null, true);
return EndGetItem(asyncResult);
}
示例15: GetItemHelper
internal Document GetItemHelper(Key key, GetItemOperationConfig config, bool isAsync)
{
var currentConfig = config ?? new GetItemOperationConfig();
var request = new GetItemRequest
{
TableName = TableName,
Key = key,
ConsistentRead = currentConfig.ConsistentRead
};
request.BeforeRequestEvent += isAsync ?
new RequestEventHandler(UserAgentRequestEventHandlerAsync) :
new RequestEventHandler(UserAgentRequestEventHandlerSync);
if (currentConfig.AttributesToGet != null)
request.WithAttributesToGet(currentConfig.AttributesToGet);
var result = DDBClient.GetItem(request);
var attributeMap = result.GetItemResult.Item;
if (attributeMap == null)
return null;
return Document.FromAttributeMap(attributeMap);
}