LongArray Method Call
Table of Contents
An LongArray Method Call is a Complex Method Call that returns a LongArray.
- See Methods for explanations of the basics and for Code examples and for the declaration of Method Calls.
See How to use Method Calls for general information on using Method Calls. - Go to the complete list of all Complex Method Calls
Code Example
The example exists of an Operation and a Form. In the operation the Entity Collection(s) and Dataview(s) are defined. The definitions of Lists and Method Call(s) for composing the data, based on input from the user, are also defined in the Forms.
Code example Operation
protected override IForm CreateStartupForm()
{
return new LongArrayMethodCallDemoFrm(this);
}
public IEntityCollection<LongArrayMethodCallDemoEntity> LongArray
{
get { return Property(() => new VolatileTable("long array").Select<LongArrayMethodCallDemoEntity>().All()); }
}
public IDataView<LongArrayMethodCallDemoEntity> LongArrayView
{
get { return Property(() => LongArray.ToView()); }
}
public IEntityCollection<ArticleEntity> Articles
{
get { return Property(() => Db.Article.Select<ArticleEntity>().All()); }
}
Explanation Code example Operation
- Lines 1-4: Definition of the Form (see code of the Form below).
- Lines 6-9: Definition of a Volatile Table. We fill this in the Form (below).
- Lines 11-14: Definition of the View, which is used to display the data in the Form.
- Lines 8 and 11: The necessary
LongArrayMethodCallDemoEntityis defined elsewhere. Type 'Volatile Table' in the Search box to read more about the working of the Volatile Table. - This
LongArrayMethodCallDemoEntityis also used in the Form below, on line 14. - Lines 16-19: We also need articles for this Code example.
Note: In this example, a Volatile Table is used. It is also possible to make a LongArray based on a Database Table.
Code example Form
public LongArrayMethodCallDemoFrm(LongArrayMethodCallDemoOp operation) : base(operation)
{
}
protected override IUIElement CreateGui()
{
return new VBox
{
new HBox
{
new GroupBox("example",2, alignV:AlignV.Top)
{
new DataGrid<LongArrayMethodCallDemoEntity>(Operation.LongArrayView, showColumnHeaders:false)
{
e => e.Value
}
}
},
new HBox(alignH:AlignH.Fill)
{
new Button(GetLongArray()),
EmptySpace.FillH,
new Button(Close())
}
};
}
private LongArray ComposeLongArray()
{
return Method(() =>
{
return new Body
{
new Return(new LongArray(Operation.Articles.Select(f => f.Vat).ToLongArray()))
};
});
}
private IMethodCall GetLongArray()
{
return Method(() =>
{
var newListItem = Operation.LongArray.CreateItemReference();
return new Body
{
Operation.LongArray.DeleteAll(),
array.Assign(ComposeLongArray()),
array.Foreach(arrayItem => new Body
{
newListItem.Assign(Operation.LongArray.New()),
newListItem.Value.Assign(listItem)
})
};
})
.SetWorkDescription("get long array")
.SetImage(WikiImages.Directory)
.Call();
}
Warning:
All Method Calls and Complex Method Calls need a new Return(). They are like C# functions that need a return type.
The exception is an IMethodCall. In C# this is like a void method.
Explanation Code example Form
- Lines 6-28: The definition of the form.
- Line 14: The View, based on the Entity (see explanation 3 and 4 of the Operation), are passed to a DataGrid.
- Lines 30-39: This is a private property of the type
LongArray. In it, the list is composed and returned (line 36). ThisLongArraywas defined in the Operation as a Volatile Table. - Line 36: Building up this
LongArrayis done with the function.ToLongArraythat collects the records collected with theSelect. - Lines 41-60: This MethodCall, named GetLongArray(), starts a new instance of
LongArrayon line 45. - Line 48: any previous data is deleted.
- Line 49-54: The composed
LongArrayis assigned to an array. By looping through this array (line 50) the items are assigned (line 52-53).
Example of the result
A form like the one defined above, could look like this.
When starting the application:

After clicking the button:
