List

A list type is an object that can hold a list of other types. When you drag a list onto the canvas, you can populate it with a list of other types.

With a list type you can, for example, make a list of strings, a list of dates, a list of Types or of any other type Linx caters for.

Properties

Type

Select the List element type, e.g. String, Bolean, Integer, List, etc

Value

The default value for the variable. This value can contain either json or xml.

list

List functions

Functions that can be performed on List in the Expression Editor:

All

Goes through the List and tests each element against a specific condition. If all of the items in the List satisfies the condition, then returns 'true'. If any item goes against the condition, then returns 'false'.

Returns: Boolean.

[List].All([condition])

Example:

ListOfStrings.All(q => q.Length > 2)

ListOfPersons.All(person => person.Email.Length > 0)


Any

Determines whether a sequence contains any elements.

Syntax:

[list].Any([(optional)condition])

Examples:

listOfCars.Any()

listOfPeople.Any(person => person.Name == "John")


Append

Returns a sequence that starts with the given sequence followed by the specified value.

Syntax:

[list].Append([element])

Example:

ListOfPeople.Append(NewPerson)


Average

Computes the average of a sequence of numeric values.

Syntax:

[list].Average([(optional)selector])

Examples:

listOfNumbers.Average()

listOfPeople.Average(person => person.Age)


Concat

Joins 2 lists together by adding the second list to the end of the first list. The List types must be the same.

Returns: List. List will be of the same type as the original two, containing all the elements.

[List].Concat([List])

Example:

List1.Concat(List2)

Contains

Check whether an item exists inside of the list.

Returns: Boolean - 'true' if List contains the item, 'false' if List does not contain item.

[List].Contains([Item])

Example:

List1.Contains("A")


Count

Returns the number of elements in a sequence.

Syntax:

[list].Count([(optional)condition])

Examples:

listOfCars.Count()

listOfPeople.Count(person => person.Name == "John")


ElementAt

Fetch an element at a specific index in the List. Important note, Lists in Linx are zero-indexed, which means the first element in the list is at index 0.

Returns: Generic. Will return the same type that the List is set as. If a List type is String, then ElementAt returns String, if List is a defined Type Person, then ElementAt returns a Person.

[List].ElementAt([Integer])

Example:

List1.ElementAt(2)

[] (Square Brackets)

Fetch an element at a specific index in the List. Important note, Lists in Linx are zero-indexed, which means the first element in the list is at index 0.

Returns: Generic. Will return the same type that the List is set as. If a List type is String, then [] returns String, if List is a defined Type Person, then [] returns a Person.

[List][[Integer]]

Example:

List1[2]

ElementAtOrDefault

Fetch an element at a specific index in the List, however if the index is out of the List’s range, then returns a default (which is <NULL> in most cases) without raising an exception.

Important note: Lists in Linx are zero-indexed, which means the first element in the list is at index 0.

Returns: Generic. Will return the same type that the List is set as. If a List type is String, then ElementAt returns String, if List is a defined Type Person, then ElementAt returns a Person.

If the index is out of the List’s range, return’s a <NULL>

[List].ElementAtOrDefault([Integer])

Example:

List1.ElementAtOrDefault(2)

First

Fetch the first element in a List.

Returns: Generic. Will return the same type that the List is set as. If a List type is String, then First returns String, if List is a defined Type Person, then First returns a Person.

[List].First()

[List].First([(optional)condition])

Example:

List1.First()

ListOfPersons.First(person => person.Name == "John")


FirstOrDefault

Fetch the first element in a List. However, if the List is empty, returns a <NULL> instead of raising an exception.

Returns: Generic. Will return the same type that the List is set as. If a List type is String, then FirstOrDefault returns String, if List is a defined Type Person, then FirstOrDefault returns a Person. If the List is empty, return’s a <NULL>

[List].FirstOrDefault()

[List].FirstOrDefault([(optional)condition])

Example:

List1.FirstOrDefault()

ListOfPersons.FirstOrDefault(person => person.Name == "John")


Last

Fetch the last element in a List.

Returns: Generic. Will return the same type that the List is set as. If a List type is String, then Last returns String, if List is a defined Type Person, then Last returns a Person.

[List].Last()

[List].Last([(optional)condition])

Example:

List1.Last()

ListOfPersons.Last(person => person.Name == "John")

LastOrDefault

Fetch the last element in a List. However, if the List is empty, returns a <NULL> instead of raising an exception.

Returns: Generic. Will return the same type that the List is set as. If a List type is String, then LastOrDefault returns String, if List is a defined Type Person, then LastOrDefault returns a Person. If the List is empty, return’s a <NULL>

[List].LastOrDefault()

[List].LastOrDefault([(optional)condition])

Example:

List1.LastOrDefault()

ListOfPersons.LastOrDefault(person => person.Name == "John")


Max

Returns the maximum value in a sequence of values.

Syntax:

[list].Max([(optional)selector])

Examples:

listOfNumbers.Max()

listOfPeople.Max(person => person.Age)


Min

Returns the minimum value in a sequence of values.

Syntax:

[list].Min([(optional)selector])

Examples:

listOfNumbers.Min()

listOfPeople.Min(person => person.Age)


OrderBy

Order a List using a specific property within the List in ascending order. For Simple types, like String, and Integer, you will still need to define the property to order by. For complex types, for instance, Person, you need to provide the property to order by, for example Name.

Returns: List<Generic>. Will return a List of the same type as the original. For instance if the original List was a List of Strings, then OrderBy returns a List<String>.

[List].OrderBy([selector])

Example:

ListOfString.OrderBy(q => q)

ListOfPersons.OrderBy(person => person.Name)


OrderByDescending

Order a List using a specific property within the List in descending order. For Simple types, like String, and Integer, you will still need to define the property to order by. For complex types, for instance, Person, you need to provide the property to order by, for example Name.

Returns: List<Generic>. Will return a List of the same type as the original. For instance if the original List was a List of Strings, then OrderBy returns a List<String>.

[List].OrderByDescending([selector])

Example:

ListOfString.OrderByDescending(q => q)

ListOfPersons.OrderByDescending(person => person.Name)


Single

Provides the only item in a List. If a list contains no items or more than one, an exception is thrown.

Returns: Generic. Will return the same type that the List is set as. If a List type is String, then Single returns String, if List is a defined Type Person, then Single returns a Person.

[List].Single()

[List].Single([(optional)condition])

Example:

List1.Single()

ListOfPersons.Single(person => person.Name == "John")


SingleOrDefault

Provides the only item in a List. Returns if the list contains no items, or throws an exception if it contains more than one item.

Returns: Generic. Will return the same type that the List is set as. If a List type is String, then Single returns String, if List is a defined Type Person, then Single returns a Person.

[List].SingleOrDefault()

[List].SingleOrDefault([(optional)condition])

Example:

List1.SingleOrDefault()

ListOfPersons.SingleOrDefault(person => person.Name == "John")


Skip

Provides a List where the first number of items are removed. You provide a number of items to skip.

Returns: List<Generic>. Will return a List of the same type as the original. For instance if the original List was a List of Strings, then Skip returns a List<String>.

[List].Skip([Integer])

Example:

List1.Skip(5)

SkipWhile

Provides a sequence that discards items as long as a specified condition is 'true' and then returns the remaining items.

Returns: List<Generic>. Will return a List of the same type as the original. For instance if the original List was a List of Strings, then SkipWhile returns a List<String>.

[List].SkipWhile([condition])

Example:

ListOfStrings.SkipWhile(q => q == "A")

ListOfPersons.SkipWhile(person => person.Name == "John")


Take

Provides a List of only the first number of items. You provide a number of items to take.

Returns: List<Generic>. Will return a List of the same type as the original. For instance if the original List was a List of Strings, then Take returns a List<String>.

[List].Take([Integer])

Example:

List1.Take(5)

TakeWhile

Provides a sequence that relays items as long as a specified condition is 'true' and then discards the remaining items.

Returns: List<Generic>. Will return a List of the same type as the original. For instance if the original List was a List of Strings, then TakeWhile returns a List<String>.

[List].TakeWhile([condition])

Example:

ListOfStrings.TakeWhile(q => q == "A")

ListOfPersons.TakeWhile(person => person.Name == "John")


Where

Goes through the List and tests each element against a specific condition, and only taking the elements which satisfies the condition.

Returns: List<Generic>. Will return a List of the same type as the original. For instance if the original List was a List of Strings, then TakeWhile returns a List<String>.

[List].Where([condition])

Example:

ListOfStrings.Where(q => q.Length > 2)

ListOfPersons.Where(person => person.Name.Length < 5)


Use the AddToList function to append values to your list dynamically.

Use the ClearList function to remove all values from a list.