Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7871383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:53:22+00:00 2026-06-03T01:53:22+00:00

I would like to check an attribute using C# and SimpleDB without having to

  • 0

I would like to check an attribute using C# and SimpleDB without having to loop through all the attributes for a specific item.

For example, if I have my domain: “MyDomain”, and I have three attributes for an item (the item is: george@george.com).

The three attributes are:

Name
Signup
Contacts

So for example this is my data:

MyDomain (domain)
  george@george.com (item)

    George Doe (attribute)
    3-1-12 (attribute)
    mike@mike.com (attribute)

The problem I am having is my code will loop through all 3 attributes in the george@george.com item.
For example; when I run my code the output is:

No Contacts Found
No Contacts Found
Contact: mike@mike.com

because my code is looping through all 3 attributes for the george@george.com item.

I want to make my C# code only check the “Contacts” attribute and NOT loop through all the attributes for the george@george.com item.

Can someone please show me how to do this?

AmazonSimpleDB sdb = AWSClientFactory.CreateAmazonSimpleDBClient();

            String selectExpression = "Select * From MyDomain Where Email = 'george@george.com'";
            SelectRequest selectRequestAction =
                new SelectRequest().WithSelectExpression(selectExpression);
            SelectResponse selectResponse = sdb.Select(selectRequestAction);

            if (selectResponse.IsSetSelectResult())
            {
                SelectResult selectResult = selectResponse.SelectResult;
                foreach (Item item in selectResult.Item)
                {

                    foreach (Amazon.SimpleDB.Model.Attribute attribute in item.Attribute)
                    {    
                        if (attribute.IsSetName())
                        {

                            if (attribute.Name == "Contact")
                            {
                                if (attribute.IsSetValue())
                                {
                                    Console.WriteLine("Contact: {0}", attribute.Value);
                                }
                            }
                            else
                            {
                                Console.WriteLine("No Contacts Found");
                            }   
                        }
                    }
                }
            }

I want it to directly just check the “Contacts” attribute to see if there is a value for it and not loop through all the attributes.

Can someone show me a C# code example on how I would accomplish this? Thanks.

EDIT: I still want to loop through all the “Contacts” in the “Contacts” attribute. I just don’t want to loop through all the attributes that don’t have the name “Contacts”. The “Contacts” attribute can hold more than one contact and I still need to get all of those from the attribute.

This line of code from Ken below:

string value = item.Attribute.First(a => a.Name == “Contact”).Value

stops the looping of the different attributes, but it only returns 1 contact from the “Contacts” attribute even though there are more than 1 contact stored in the “Contacts” attribute.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T01:53:24+00:00Added an answer on June 3, 2026 at 1:53 am

    You can run Amazon simpleDB Query with Attribute.

    select <attribute_name> from <domain_name>
    

    And Amazon SimpleDB will return only items that have this attribute and in response you will get only this attribute even items have other attributes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to check if my menu contains the menu item Admin. Admin
I would like to check my JavaScript files without going to JSLint web site.
I would like to check if an object is defined or exists using C#.
I would like to check if there are blank embedded forms into my form,
I would like to check in which country the user is - I have
I would like to check whether an image has a lot of homogeneous areas.
I would like to check which type of RAM my computer uses before I
I would like to check if a few URL's exst on my old website
I would like to check whether the request is XML od HTML. When HTML
I would like to check the memory consumption of each running processes individually, cat

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.