public Select ( SelectRequest request ) : SelectResponse | ||
request | SelectRequest | Container for the necessary parameters to execute the Select service method. |
Résultat | SelectResponse |
public Routes GetAllRoutes() { Routes routes = new Routes(); using (AmazonSimpleDBClient client = new AmazonSimpleDBClient(_publicKey, _secretKey)) { SelectRequest request = new SelectRequest().WithSelectExpression( string.Format("SELECT * FROM Routes ")); SelectResponse response = client.Select(request); foreach (Item item in response.SelectResult.Item) { string value = item.Attribute.GetValueByName("Id"); Route route = new Route { Id = Guid.Parse(item.Attribute.GetValueByName("Id")), Distance = item.Attribute.GetDoubleValueByName("Distance"), LastTimeRidden = item.Attribute.GetDateTimeValueByName("LastTimeRidden"), Name = item.Attribute.GetValueByName("Name"), Location = item.Attribute.GetValueByName("Location"), }; routes.Add(route); } } return routes; }
protected void Page_Load(object sender, EventArgs e) { this._domainName = String.Format(Settings.Default.SimpleDbDomainNameFormat, this.Context.User.Identity.Name); if (!this.Page.IsPostBack) { using (AmazonSimpleDBClient sdbClient = new AmazonSimpleDBClient(Amazon.RegionEndpoint.USWest2)) { DomainHelper.CheckForDomain(this._domainName, sdbClient); SelectRequest selectRequest = new SelectRequest().WithSelectExpression(String.Format("select * from `{0}`", this._domainName)); SelectResponse selectResponse = sdbClient.Select(selectRequest); List<Item> items = selectResponse.SelectResult.Item; List<Pet> pets = items.Select(l => new Pet { Id = l.Name, PhotoThumbUrl = l.Attribute.First(a => a.Name == "PhotoThumbUrl").Value, Name = l.Attribute.First(a => a.Name == "Name").Value, Birthdate = l.Attribute.First(a => a.Name == "Birthdate").Value, Sex = l.Attribute.First(a => a.Name == "Sex").Value, Type = l.Attribute.First(a => a.Name == "Type").Value, Breed = l.Attribute.First(a => a.Name == "Breed").Value }).ToList(); this.PetRepeater.DataSource = pets; this.PetRepeater.DataBind(); } } }
public Profiles GetProfileList() { Profiles profiles = new Profiles(); using(AmazonSimpleDBClient client = new AmazonSimpleDBClient(_publicKey, _secretKey)) { SelectRequest request = new SelectRequest { SelectExpression = "SELECT * FROM Profiles" }; SelectResponse response = client.Select(request); var list = from item in response.SelectResult.Item select new Profile() { Id = Guid.Parse(item.Attribute.GetValueByName("Id")), Description = item.Attribute.GetValueByName("Description"), Location = item.Attribute.GetValueByName("Location"), Name = item.Attribute.GetValueByName("Name") }; foreach (Profile profile in list) { profiles.Add(profile); } } return profiles; }
public static List<Tags> GetTags(string domainName, AmazonSimpleDBClient sdbClient) { List<Tags> tagses = new List<Tags>(); Tags tags; String selectExpression = "Select TagId,TagName,Country From " + domainName; SelectRequest selectRequestAction = new SelectRequest().WithSelectExpression(selectExpression); SelectResponse selectResponse = sdbClient.Select(selectRequestAction); if (selectResponse.IsSetSelectResult()) { SelectResult selectResult = selectResponse.SelectResult; foreach (Item item in selectResult.Item) { tags = new Tags(); ; if (item.IsSetName()) { } int i = 0; foreach (Amazon.SimpleDB.Model.Attribute attribute in item.Attribute) { if (attribute.IsSetName()) { string name = attribute.Name; } if (attribute.IsSetValue()) { switch (attribute.Name) { case "TagId": tags.TagId = Guid.Parse(attribute.Value); break; case "TagName": tags.TagName = attribute.Value; break; case "Country": tags.Country = attribute.Value; break; } i++; } } tagses.Add(tags); } } return tagses; }
public bool CheckAuthentication(string userName, string password) { bool success = false; using (AmazonSimpleDBClient client = new AmazonSimpleDBClient(_publicKey, _secretKey)) { SelectRequest request = new SelectRequest().WithSelectExpression(string.Format("SELECT Id FROM Profiles where Username = '******' and Password='******'", userName, password)); SelectResponse response = client.Select(request); if (response.SelectResult.Item.Count>0) { success = true; AuthenticatedUser = Guid.Parse(response.SelectResult.Item.First().Name); } } return success; }
public List<Route> GetUsersRoutes(Guid userId) { List<Route> list = new List<Route>(); using (AmazonSimpleDBClient client = new AmazonSimpleDBClient(_publicKey, _secretKey)) { SelectRequest request = new SelectRequest().WithSelectExpression( string.Format("SELECT RouteId FROM ProfileRoutes where ProfileId = '{0}'", userId)); SelectResponse response = client.Select(request); foreach (Item routeItem in response.SelectResult.Item) { list.Add(new Route() { Id =Guid.Parse(routeItem.Attribute.GetValueByName("RouteId")) }); } } return list; }
public Route GetRouteById(Guid routeId) { Route route = new Route(); using (AmazonSimpleDBClient client = new AmazonSimpleDBClient(_publicKey, _secretKey)) { SelectRequest request = new SelectRequest().WithSelectExpression( string.Format("SELECT * FROM Routes where Id = '{0}'", routeId)); SelectResponse response = client.Select(request); if (response.SelectResult.Item.Count>0) { route.Id = Guid.Parse(response.SelectResult.Item[0].Attribute.GetValueByName("Id")); route.Distance = response.SelectResult.Item[0].Attribute.GetDoubleValueByName("Distance"); route.LastTimeRidden = response.SelectResult.Item[0].Attribute.GetDateTimeValueByName("LastTimeRidden"); } } return route; }
public Profile GetProfileById(Guid id) { Profile profile; using (AmazonSimpleDBClient client = new AmazonSimpleDBClient(_publicKey, _secretKey)) { SelectRequest request = new SelectRequest().WithSelectExpression(string.Format("SELECT * FROM Profiles where Id = '{0}'",id)); SelectResponse response = client.Select(request); profile = (from item in response.SelectResult.Item select new Profile() { Id = Guid.Parse(item.Attribute.GetValueByName("Id")), Description = item.Attribute.GetValueByName("Description"), Location = item.Attribute.GetValueByName("Location"), Name = item.Attribute.GetValueByName("Name") }).First(); } return profile; }
public static List<NewsComponents> GetNewsStories(string domainName, AmazonSimpleDBClient sdbClient) { List<NewsComponents> newsItems = new List<NewsComponents>(); NewsComponents newsItem = null; String selectExpression = "Select NewsID,Source,Section,Publish,NewsHeadline,NewsAdded,Photos,Summary,Category From " + domainName; SelectRequest selectRequestAction = new SelectRequest().WithSelectExpression(selectExpression); SelectResponse selectResponse = sdbClient.Select(selectRequestAction); if (selectResponse.IsSetSelectResult()) { SelectResult selectResult = selectResponse.SelectResult; foreach (Item item in selectResult.Item) { newsItem = new NewsComponents(); if (item.IsSetName()) { } int i = 0; foreach (Amazon.SimpleDB.Model.Attribute attribute in item.Attribute) { if (attribute.IsSetName()) { string name = attribute.Name; } if (attribute.IsSetValue()) { switch (attribute.Name) { case "NewsID": newsItem.NewsID = Guid.Parse(attribute.Value); break; case "Source": newsItem.Source = attribute.Value; break; case "Section": newsItem.Section = attribute.Value; break; case "NewsItem": newsItem.NewsItem = attribute.Value; break; case "NewsHeadline": newsItem.NewsHeadline = attribute.Value; break; case "Publish": newsItem.Publish = Convert.ToBoolean(attribute.Value); break; case "NewsAdded": newsItem.NewsAdded = Convert.ToDateTime(attribute.Value); break; case "Photos": newsItem.NewsPhotoUrl = attribute.Value; break; case "Summary": newsItem.NewsItem = GetTheHtml(attribute.Value); break; case "Category": newsItem.Category = attribute.Value; break; case "SummaryContent": newsItem.SummaryContent = attribute.Value; break; } i++; } } newsItems.Add(newsItem); } } return newsItems; }
static void ReadFromSimpleDb(AWSCredentials credentials) { var client = new AmazonSimpleDBClient(credentials, RegionEndpoint.USEast1); // attribute names are case sensitive // comparisons are lexicographical. no numeric comparisons exist var request = new SelectRequest("select * from `aws-talk` WHERE `Price` > '01'"); var response = client.Select(request); foreach (var item in response.Items) { Console.WriteLine("Item {0} has attributes: {1}", item.Name, String.Join(" ; ", item.Attributes.Select(a => string.Format("{0}={1}", a.Name, a.Value)))); } }