Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 234
  • Last Modified:

How to I add a new value based on a change of value

Hi there

How to I add a new value based on a change of value?

I have this code

 foreach (var item in itemAttributes)
        {            
            string fID = GetBook("Programming");
            var attributes = from a in itemAttributes
                             where a.Description.ToLower().Contains("ID='" + fID + "'")

            SearchBookCollection values = new SearchBookCollection();
            values.AddRange(attributes.ToList());
        }

What I want is if fID are different ONLY run

values.AddRange(attributes.ToList());

Hope this makes sense?

thanks
0
mousemat24
Asked:
mousemat24
1 Solution
 
Arthur_WoodCommented:
this line:

var attributes = from a in itemAttributes
                             where a.Description.ToLower().Contains("ID='" + fID + "'")


will never return any values.  You are converting the Description value to ALL LOWER case charaters, and then trying to find if that contains a value which includes UPPER case characters ("ID=").  Obviously that condition will never be met.

AW
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now