本文整理汇总了C#中Amazon.DynamoDBv2.Model.ScanRequest类的典型用法代码示例。如果您正苦于以下问题:C# ScanRequest类的具体用法?C# ScanRequest怎么用?C# ScanRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScanRequest类属于Amazon.DynamoDBv2.Model命名空间,在下文中一共展示了ScanRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getItemContain
public List<Dictionary<string, AttributeValue>> getItemContain(string ConnectionString, string tableName, string inputparam, string columnName)
{
Connection c = new Connection();
var client = c.ConnectAmazonDynamoDB(ConnectionString);
var table = Table.LoadTable(client, tableName);
// Define scan conditions
Dictionary<string, Condition> conditions = new Dictionary<string, Condition>();
// Title attribute should contain the string "Adventures"
Condition titleCondition = new Condition();
titleCondition.ComparisonOperator = "BEGINS_WITH";
titleCondition.AttributeValueList.Add(new AttributeValue { S = inputparam });
conditions[columnName] = titleCondition;
var request = new ScanRequest
{
TableName = tableName,
ScanFilter = conditions
};
var response = client.Scan(request);
var result = response.Items;
return result;
}
示例2: InstantiateIn
public void InstantiateIn(System.Web.UI.Control container)
{
AmazonDynamoDBClient client = new AmazonDynamoDBClient();
// string tableName = "Attendee";
var request = new ScanRequest
{
TableName = "QuizQuestion",
};
var response = client.Scan(request);
List<QuestionData> questionDataList = new List<QuestionData>();
foreach (Dictionary<string, AttributeValue> item in response.ScanResult.Items)
{
// Process the result.
QuestionData question = new QuestionData();
if (item.ContainsKey("options"))
{
foreach (var itemNew in item["options"].M)
{
Label link = new Label();
link.ID = "linkmodel";
container.Controls.Add(link);
link.Text = itemNew.Value.S;
//Label value = questionData.FindControl("options") as Label;
////testM = itemNew.Key.ToString();
//value.Text = itemNew.Value.S;
}
}
}
}
示例3: getAllItems
public List<Dictionary<string,AttributeValue>> getAllItems(string ConnectionString, string tableName)
{
Connection c = new Connection();
var client = c.ConnectAmazonDynamoDB(ConnectionString);
var request = new ScanRequest
{
TableName = tableName,
};
var response = client.Scan(request);
var result = response.Items;
return result;
}
示例4: getItem
public List<Dictionary<string, AttributeValue>> getItem(string ConnectionString, string tableName, string inputparam, string expressionText, string columnName)
{
Connection c = new Connection();
var client = c.ConnectAmazonDynamoDB(ConnectionString);
var table = Table.LoadTable(client, tableName);
var request = new ScanRequest
{
TableName = tableName,
ExpressionAttributeValues = new Dictionary<string, AttributeValue> {
{expressionText, new AttributeValue { S = inputparam}}
},
FilterExpression = columnName + "=" + expressionText
};
var response = client.Scan(request);
var result = response.Items;
return result;
}
示例5: GetNextSetHelper
private List<Document> GetNextSetHelper(bool isAsync)
{
List<Document> ret = new List<Document>();
if (!IsDone)
{
switch (SearchMethod)
{
case SearchType.Scan:
ScanRequest scanReq = new ScanRequest
{
ExclusiveStartKey = NextKey,
Limit = Limit,
TableName = TableName,
AttributesToGet = AttributesToGet,
ScanFilter = Filter,
Select = EnumToStringMapper.Convert(Select)
};
if (this.TotalSegments != 0)
{
scanReq.TotalSegments = this.TotalSegments;
scanReq.Segment = this.Segment;
}
scanReq.BeforeRequestEvent += isAsync ?
new RequestEventHandler(SourceTable.UserAgentRequestEventHandlerAsync) :
new RequestEventHandler(SourceTable.UserAgentRequestEventHandlerSync);
ScanResult scanResult = SourceTable.DDBClient.Scan(scanReq).ScanResult;
foreach (var item in scanResult.Items)
{
Document doc = Document.FromAttributeMap(item);
ret.Add(doc);
if (CollectResults)
{
Matches.Add(doc);
}
}
NextKey = scanResult.LastEvaluatedKey;
if (NextKey == null)
{
IsDone = true;
}
return ret;
case SearchType.Query:
QueryRequest queryReq = new QueryRequest
{
ConsistentRead = IsConsistentRead,
ExclusiveStartKey = NextKey,
Limit = Limit,
ScanIndexForward = !IsBackwardSearch,
TableName = TableName,
AttributesToGet = AttributesToGet,
KeyConditions = Filter,
IndexName = IndexName,
Select = EnumToStringMapper.Convert(Select)
};
queryReq.BeforeRequestEvent += isAsync ?
new RequestEventHandler(SourceTable.UserAgentRequestEventHandlerAsync) :
new RequestEventHandler(SourceTable.UserAgentRequestEventHandlerSync);
QueryResult queryResult = SourceTable.DDBClient.Query(queryReq).QueryResult;
foreach (var item in queryResult.Items)
{
Document doc = Document.FromAttributeMap(item);
ret.Add(doc);
if (CollectResults)
{
Matches.Add(doc);
}
}
NextKey = queryResult.LastEvaluatedKey;
if (NextKey == null)
{
IsDone = true;
}
return ret;
default:
throw new InvalidOperationException("Unknown Search Method");
}
}
return ret;
}
示例6: ScanAsync
/// <summary>
/// Initiates the asynchronous execution of the Scan operation.
/// <seealso cref="Amazon.DynamoDBv2.IAmazonDynamoDB"/>
/// </summary>
///
/// <param name="request">Container for the necessary parameters to execute the Scan 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<ScanResponse> ScanAsync(ScanRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
{
var marshaller = new ScanRequestMarshaller();
var unmarshaller = ScanResponseUnmarshaller.Instance;
return InvokeAsync<ScanRequest,ScanResponse>(request, marshaller,
unmarshaller, cancellationToken);
}
示例7: GetCount
private int GetCount()
{
if (IsDone && CollectResults)
{
return Matches.Count;
}
else
{
if (count != -1)
{
return count;
}
else
{
switch (SearchMethod)
{
case SearchType.Scan:
ScanRequest scanReq = new ScanRequest
{
TableName = TableName,
Select = EnumMapper.Convert(SelectValues.Count),
ExclusiveStartKey = NextKey,
ScanFilter = Filter.ToConditions(SourceTable.Conversion),
};
if (this.FilterExpression != null && this.FilterExpression.IsSet)
{
this.FilterExpression.ApplyExpression(scanReq, SourceTable.Conversion);
}
if (scanReq.ScanFilter != null && scanReq.ScanFilter.Count > 1)
scanReq.ConditionalOperator = EnumMapper.Convert(ConditionalOperator);
if (this.TotalSegments != 0)
{
scanReq.TotalSegments = this.TotalSegments;
scanReq.Segment = this.Segment;
}
scanReq.BeforeRequestEvent += SourceTable.UserAgentRequestEventHandlerSync;
ScanResult scanResult = SourceTable.DDBClient.Scan(scanReq);
count = Matches.Count + scanResult.Count;
return count;
case SearchType.Query:
QueryRequest queryReq = new QueryRequest
{
TableName = TableName,
ConsistentRead = IsConsistentRead,
Select = EnumMapper.Convert(SelectValues.Count),
ExclusiveStartKey = NextKey,
ScanIndexForward = !IsBackwardSearch,
IndexName = IndexName
};
if (this.FilterExpression != null && this.FilterExpression.IsSet)
{
this.FilterExpression.ApplyExpression(queryReq, SourceTable.Conversion);
}
Dictionary<string, Condition> keyConditions, filterConditions;
SplitQueryFilter(Filter, SourceTable, queryReq.IndexName, out keyConditions, out filterConditions);
queryReq.KeyConditions = keyConditions;
queryReq.QueryFilter = filterConditions;
if (queryReq.QueryFilter != null && queryReq.QueryFilter.Count > 1)
queryReq.ConditionalOperator = EnumMapper.Convert(ConditionalOperator);
queryReq.BeforeRequestEvent += SourceTable.UserAgentRequestEventHandlerSync;
QueryResult queryResult = SourceTable.DDBClient.Query(queryReq);
count = Matches.Count + queryResult.Count;
return count;
default:
throw new InvalidOperationException("Unknown Search Method");
}
}
}
}
示例8: Scan
/// <summary>
/// <para>The <i>Scan</i> operation returns one or more items and item attributes by accessing every item in the table. To have Amazon DynamoDB
/// return fewer items, you can provide a <i>ScanFilter</i> .</para> <para>If the total number of scanned items exceeds the maximum data set
/// size limit of 1 MB, the scan stops and results are returned to the user with a <i>LastEvaluatedKey</i> to continue the scan in a subsequent
/// operation. The results also include the number of items exceeding the limit. A scan can result in no table data meeting the filter criteria.
/// </para> <para>The result set is eventually consistent. </para> <para>By default, <i>Scan</i> operations proceed sequentially; however, for
/// faster performance on large tables, applications can perform a parallel <i>Scan</i> by specifying the <i>Segment</i> and
/// <i>TotalSegments</i> parameters. For more information, see Parallel Scan in the <i>Amazon DynamoDB Developer Guide</i> .</para>
/// </summary>
///
/// <param name="scanRequest">Container for the necessary parameters to execute the Scan service method on AmazonDynamoDBv2.</param>
///
/// <returns>The response from the Scan service method, as returned by AmazonDynamoDBv2.</returns>
///
/// <exception cref="ResourceNotFoundException"/>
/// <exception cref="ProvisionedThroughputExceededException"/>
/// <exception cref="InternalServerErrorException"/>
public ScanResponse Scan(ScanRequest scanRequest)
{
IAsyncResult asyncResult = invokeScan(scanRequest, null, null, true);
return EndScan(asyncResult);
}
示例9: invokeScan
IAsyncResult invokeScan(ScanRequest scanRequest, AsyncCallback callback, object state, bool synchronized)
{
IRequest irequest = new ScanRequestMarshaller().Marshall(scanRequest);
var unmarshaller = ScanResponseUnmarshaller.GetInstance();
AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
Invoke(result);
return result;
}
示例10: Scan
/// <summary>
/// The <i>Scan</i> operation returns one or more items and item attributes by accessing
/// every item in a table or a secondary index. To have DynamoDB return fewer items, you
/// can provide a <i>ScanFilter</i> operation.
///
///
/// <para>
/// If the total number of scanned items exceeds the maximum data set size limit of 1
/// MB, the scan stops and results are returned to the user as a <i>LastEvaluatedKey</i>
/// value to continue the scan in a subsequent operation. The results also include the
/// number of items exceeding the limit. A scan can result in no table data meeting the
/// filter criteria.
/// </para>
///
/// <para>
/// The result set is eventually consistent.
/// </para>
///
/// <para>
/// By default, <i>Scan</i> operations proceed sequentially; however, for faster performance
/// on a large table or secondary index, applications can request a parallel <i>Scan</i>
/// operation by providing the <i>Segment</i> and <i>TotalSegments</i> parameters. For
/// more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html#QueryAndScanParallelScan">Parallel
/// Scan</a> in the <i>Amazon DynamoDB Developer Guide</i>.
/// </para>
/// </summary>
/// <param name="tableName">The name of the table containing the requested items; or, if you provide <code>IndexName</code>, the name of the table to which that index belongs.</param>
/// <param name="scanFilter"><important> This is a legacy parameter, for backward compatibility. New applications should use <i>FilterExpression</i> instead. Do not combine legacy parameters and expression parameters in a single API call; otherwise, DynamoDB will return a <i>ValidationException</i> exception. </important> A condition that evaluates the scan results and returns only the desired values. <note>This parameter does not support attributes of type List or Map.</note> If you specify more than one condition in the <i>ScanFilter</i> map, then by default all of the conditions must evaluate to true. In other words, the conditions are ANDed together. (You can use the <i>ConditionalOperator</i> parameter to OR the conditions instead. If you do this, then at least one of the conditions must evaluate to true, rather than all of them.) Each <i>ScanFilter</i> element consists of an attribute name to compare, along with the following: <ul> <li> <i>AttributeValueList</i> - One or more values to evaluate against the supplied attribute. The number of values in the list depends on the operator specified in <i>ComparisonOperator</i> . For type Number, value comparisons are numeric. String value comparisons for greater than, equals, or less than are based on ASCII character code values. For example, <code>a</code> is greater than <code>A</code>, and <code>a</code> is greater than <code>B</code>. For a list of code values, see <a href="http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters">http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters</a>. For Binary, DynamoDB treats each byte of the binary data as unsigned when it compares binary values. For information on specifying data types in JSON, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataFormat.html">JSON Data Format</a> in the <i>Amazon DynamoDB Developer Guide</i>. </li> <li> <i>ComparisonOperator</i> - A comparator for evaluating attributes. For example, equals, greater than, less than, etc. The following comparison operators are available: <code>EQ | NE | LE | LT | GE | GT | NOT_NULL | NULL | CONTAINS | NOT_CONTAINS | BEGINS_WITH | IN | BETWEEN</code> For complete descriptions of all comparison operators, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Condition.html">Condition</a>. </li> </ul></param>
///
/// <returns>The response from the Scan 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 ScanResponse Scan(string tableName, Dictionary<string, Condition> scanFilter)
{
var request = new ScanRequest();
request.TableName = tableName;
request.ScanFilter = scanFilter;
return Scan(request);
}
示例11: Get_all_items_with_AWSSDK
public void Get_all_items_with_AWSSDK()
{
db.PutItem(new Todo { Id = 1, Content = "TODO 1", Order = 1 });
var request = new ScanRequest
{
TableName = "Todo",
Limit = 1000,
};
var allTodos = new List<Todo>();
ScanResponse response = null;
do
{
if (response != null)
request.ExclusiveStartKey = response.LastEvaluatedKey;
response = awsDb.Scan(request);
foreach (var item in response.Items)
{
var todo = new Todo
{
Id = Convert.ToInt64(item["Id"].N),
Content = item["Content"].S,
Order = Convert.ToInt32(item["Order"].N),
Done = item["Done"].BOOL,
};
allTodos.Add(todo);
}
} while (response.LastEvaluatedKey != null && response.LastEvaluatedKey.Count > 0);
allTodos.PrintDump();
}
示例12: ScanAsync
/// <summary>
/// Initiates the asynchronous execution of the Scan operation.
/// <seealso cref="Amazon.DynamoDBv2.IAmazonDynamoDB.Scan"/>
/// </summary>
///
/// <param name="request">Container for the necessary parameters to execute the Scan 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 async Task<ScanResponse> ScanAsync(ScanRequest request, CancellationToken cancellationToken = default(CancellationToken))
{
var marshaller = new ScanRequestMarshaller();
var unmarshaller = ScanResponseUnmarshaller.GetInstance();
var response = await Invoke<IRequest, ScanRequest, ScanResponse>(request, marshaller, unmarshaller, signer, cancellationToken)
.ConfigureAwait(continueOnCapturedContext: false);
return response;
}
示例13: SearchSamples
//.........这里部分代码省略.........
} while (startKey != null && startKey.Count > 0);
#endregion
}
{
#region Scan Sample
// Create a client
AmazonDynamoDBClient client = new AmazonDynamoDBClient();
// Define scan conditions
Dictionary<string, Condition> conditions = new Dictionary<string, Condition>();
// Title attribute should contain the string "Adventures"
Condition titleCondition = new Condition();
titleCondition.ComparisonOperator = ComparisonOperator.CONTAINS;
titleCondition.AttributeValueList.Add(new AttributeValue { S = "Adventures" });
conditions["Title"] = titleCondition;
// Pages attributes must be greater-than the numeric value "200"
Condition pagesCondition = new Condition();
pagesCondition.ComparisonOperator = ComparisonOperator.GT;;
pagesCondition.AttributeValueList.Add(new AttributeValue { N = "200" });
conditions["Pages"] = pagesCondition;
// Define marker variable
Dictionary<string, AttributeValue> startKey = null;
do
{
// Create Scan request
ScanRequest request = new ScanRequest
{
TableName = "SampleTable",
ExclusiveStartKey = startKey,
ScanFilter = conditions
};
// Issue request
ScanResult result = client.Scan(request);
// View all returned items
List<Dictionary<string, AttributeValue>> items = result.Items;
foreach (Dictionary<string, AttributeValue> item in items)
{
Console.WriteLine("Item:");
foreach (var keyValuePair in item)
{
Console.WriteLine("{0} : S={1}, N={2}, SS=[{3}], NS=[{4}]",
keyValuePair.Key,
keyValuePair.Value.S,
keyValuePair.Value.N,
string.Join(", ", keyValuePair.Value.SS ?? new List<string>()),
string.Join(", ", keyValuePair.Value.NS ?? new List<string>()));
}
}
// Set marker variable
startKey = result.LastEvaluatedKey;
} while (startKey != null && startKey.Count > 0);
#endregion
}
示例14: ScanAsync
/// <summary>
/// Initiates the asynchronous execution of the Scan operation.
/// </summary>
///
/// <param name="request">Container for the necessary parameters to execute the Scan operation on AmazonDynamoDBClient.</param>
/// <param name="callback">An Action delegate that is invoked when the operation completes.</param>
/// <param name="options">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>
public void ScanAsync(ScanRequest request, AmazonServiceCallback<ScanRequest, ScanResponse> callback, AsyncOptions options = null)
{
options = options == null?new AsyncOptions():options;
var marshaller = new ScanRequestMarshaller();
var unmarshaller = ScanResponseUnmarshaller.Instance;
Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;
if(callback !=null )
callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => {
AmazonServiceResult<ScanRequest,ScanResponse> responseObject
= new AmazonServiceResult<ScanRequest,ScanResponse>((ScanRequest)req, (ScanResponse)res, ex , ao.State);
callback(responseObject);
};
BeginInvoke<ScanRequest>(request, marshaller, unmarshaller, options, callbackHelper);
}
示例15: ScanAsync
/// <summary>
/// <para>The <i>Scan</i> operation returns one or more items and item attributes by accessing every item in the table. To have DynamoDB return
/// fewer items, you can provide a <i>ScanFilter</i> .</para> <para>If the total number of scanned items exceeds the maximum data set size limit
/// of 1 MB, the scan stops and results are returned to the user with a <i>LastEvaluatedKey</i> to continue the scan in a subsequent operation.
/// The results also include the number of items exceeding the limit. A scan can result in no table data meeting the filter criteria. </para>
/// <para>The result set is eventually consistent. </para> <para>By default, <i>Scan</i> operations proceed sequentially; however, for faster
/// performance on large tables, applications can request a parallel <i>Scan</i> by specifying the <i>Segment</i> and <i>TotalSegments</i>
/// parameters. For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html#QueryAndScanParallelScan">Parallel Scan</a> in the
/// Amazon DynamoDB Developer Guide.</para>
/// </summary>
///
/// <param name="scanRequest">Container for the necessary parameters to execute the Scan service method on AmazonDynamoDBv2.</param>
///
/// <returns>The response from the Scan 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<ScanResponse> ScanAsync(ScanRequest scanRequest, CancellationToken cancellationToken = default(CancellationToken))
{
var marshaller = new ScanRequestMarshaller();
var unmarshaller = ScanResponseUnmarshaller.GetInstance();
return Invoke<IRequest, ScanRequest, ScanResponse>(scanRequest, marshaller, unmarshaller, signer, cancellationToken);
}