enter code here
I have GlobalTerms class that contains a data member terms which is a list of type Term.
Each Term class has 3 members.
- int Id;
- bool IsApproved;
- string Note;
so, it looks like:
Class GlobalTerms
{
IEnumerable<TermInfo> UserTerms;
}
Class TermInfo
{
public int Id { get; set; }
public string Note{ get; set; }
public bool IsApproved{ get; set; }
}
If I have an GlobalTerms object (globalTerms), how can I get a TermInfo object where the Status in TermInfo equals True?
I tried to write something like this:
GlobalTerms globalTerms = new GlobalTerms();
globalTerms.UserTerms.Where(x => x.IsApproved.Equals(true))
.Select(x => x.Id);
My task was checking that all items in UserTerms has true in IsApproved field; In result I received error: System.ArgumentNullException: Value cannot be null. Parameter name: source Thank you in advance for your help,
ANSWER: In result, this issue was solved used the next code:
*termsList* - is a IList<GlobalTerms>
foreach (var singleTerm in termsList)
{
var sourceTermsList = singleTerm.UserTerms.ToList();
foreach (var status in sourceTermsList)
{
status.IsApproved.Should().BeTrue();
}
}
Thank Guys to everyone,