|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2011-04-13 12:29:45
Posts: 75,
Visits: 544
|
|
I Have following ocl =
"SystemUser.allInstances->Collect(p|p.FirstName,p.LastName)"
i want to get result elements as List.
i evaluating expression, in returns IElementCollection - >class ElementCollectionConstantImpl
when i evaluate
for example this code ocl("SystemUser.allInstances->Collect(p|p.FirstName,p.LastName)")
code
var sp = EcoSpace;
var ocl = sp.GetEcoService();
new SystemUser(sp) { Age = 1, FirstName = "George", LastName = "Harrison" };
new SystemUser(sp) { Age = 1, FirstName = "John", LastName = "Lenon" };
new SystemUser(sp) { Age = 1, FirstName = "Pol", LastName = "McCartney" };
var result = ocl.Evaluate("SystemUser.allInstances->Collect(p|p.FirstName,p.LastName)");
try
{
var res = result.AsObject;
}
catch(Exception ex)
{
MessageBox.Show(ex.Message,"Exception" ); //--> throws here
}
var lst = new List();
foreach (var obj in (IElementCollection)result)
{
lst.Add((IElement)obj);
}
MessageBox.Show(string.Format("Manual Collection contains {0} elements",lst.Count), "Exception");
if evaluation contains no items any exception is thrown.
is it bug?
any way i will post bugreport.
http://magpie.no-ip.com/mantis/view.php?id=902
Alex
|
|
|
|