TechTalk Genome v4.2

Set.ToObject Method 

Returns the only element of this Set.

public object ToObject();

Return Value

A null reference if set is empty; the first (and only) element of set if it contains one element

Remarks

The method returns the only element of this Set or a null reference if the Set is empty.

The method should not be called for sets that may contain more than one elements. Calling the method for these kinds of sets will result in different behaviours based on the database platform and the calling context. If you need to retrieve the first element of a set, the combination of GetRange and ToObject has to be used like in the following example.

                    
Set employees = dd.Extent(typeof(Employee))["Name.IsLike({0})", "A%"];
Employee firstWithA = (Employee)employees.GetRange(0, 1).ToObject();
                
As a result of this example, the variable firstWithA will contain either a null reference or the first employee matching the criteria.

Requirements

Namespace: TechTalk.Genome

Assembly: TechTalk.Genome (in TechTalk.Genome.dll)

Version: 4.2.4.4

Editions: Professional, Evaluation, Express

See Also

Set Class | TechTalk.Genome Namespace | ToObject