CapableObjects forum



Beginer's question:how to get objects in MvcEcoProject?

Posted By Scott 2009-05-12 10:00:47
Add to Favorites0
Author Message
Scott
 Posted 2009-05-12 10:00:47
Supreme Being

Supreme Being - (220 reputation)Supreme Being - (220 reputation)Supreme Being - (220 reputation)Supreme Being - (220 reputation)Supreme Being - (220 reputation)Supreme Being - (220 reputation)Supreme Being - (220 reputation)Supreme Being - (220 reputation)Supreme Being - (220 reputation)

Group: Forum Members
Last Active: 2012-01-13 13:30:02
Posts: 34, Visits: 495
220
namespace MvcEcoProject1.Controllers
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using Eco.ObjectRepresentation;
   
    public class HomeController : EcoController
    {
        #region constructors
        //Note the two constructors, one with param is for unit testing
        //Note the inheritance on this class too
        public HomeController()
            : base()
        {
        }

        public HomeController(IEcoServiceProvider testServiceProvider)
            : base(testServiceProvider)
        {
        }
        #endregion

        public ActionResult Index()
        {
            string ocl = "Calss1.Allinstances->first";
            ViewData["Title"] = "Home Page";
            ViewData["Message"] = "Welcome to ASP.NET MVC!";

               Class1 ob = this.ServiceProvider.GetEcoService<IOclService>.Excute(ocl);

               ViewData["yyy"] = Class1.Hello; // "hello,world!";

            return View();
        }

        public ActionResult About()
        {
            ViewData["Title"] = "About Page";

            return View();
        }

    }
}

it not work certainly,can anyone give me a sample code.

-----------------------
/Just do it

Scott
 Posted 2009-05-12 10:35:04
Supreme Being

Supreme Being - (220 reputation)Supreme Being - (220 reputation)Supreme Being - (220 reputation)Supreme Being - (220 reputation)Supreme Being - (220 reputation)Supreme Being - (220 reputation)Supreme Being - (220 reputation)Supreme Being - (220 reputation)Supreme Being - (220 reputation)

Group: Forum Members
Last Active: 2012-01-13 13:30:02
Posts: 34, Visits: 495
220
    using Eco.Services;
   
    public class HomeController : EcoController
    {
        #region constructors
        //Note the two constructors, one with param is for unit testing
        //Note the inheritance on this class too
        public HomeController()
            : base()
        {
        }

        public HomeController(IEcoServiceProvider testServiceProvider)
            : base(testServiceProvider)
        {
        }
        #endregion

        public ActionResult Index()
        {
            string ocl = "Class1.allInstances->first";

            ViewData["Title"] = "Home Page";
            ViewData["Message"] = "Welcome to ASP.NET MVC!";

            Class1 ob = this.ServiceProvider.GetEcoService<IOclService>().Evaluate(ocl).GetValue<Class1>();


            ViewData["yyy"] = ob.Hello; // "hello,world!";

            return View();
        }

BigGrin  It's ok!

is there more way?

-----------------------
/Just do it

Scott Price
 Posted 2009-05-12 16:54:55
Supreme Being

Supreme Being - (1 192 reputation)Supreme Being - (1 192 reputation)Supreme Being - (1 192 reputation)Supreme Being - (1 192 reputation)Supreme Being - (1 192 reputation)Supreme Being - (1 192 reputation)Supreme Being - (1 192 reputation)Supreme Being - (1 192 reputation)Supreme Being - (1 192 reputation)

Group: Forum Members
Last Active: 2012-01-27 19:06:44
Posts: 189, Visits: 777
You can use handles still to return collections you want to use, though I tend to use the style you have used, with some modifications.

I try to keep them in helper methods, so those methods themselves can be unit tested to ensure they are working as expected. They can then be used in multiple locations with the same result.

However, I would recommend you use the OclPsService first to do in-db evaluations, which require you return a collection first, and then after that further filter with the OclService. Something like this perhaps:

IOclPsService psService = EcoServiceHelper.GetOclPsService(ServiceProvider);
IOclService oclService = EcoServiceHelper.GetOclService(ServiceProvider);

// Here we return only those that meet a criteria, i.e. have bool IsVisible of true
IObjectList result = psService.Execute("myClass.allInstances->select(mc | mc.IsVisible)");

// Here we could further refine the loaded myClass objects by more criteria
result = oclService.Evaluate("myClass.allLoadedObjects") as IObjectList;
return result.GetAsIList();

I hope that is of some help to you.


Kind regards, Scott Smile
Scott
 Posted 2009-05-15 16:06:55
Supreme Being

Supreme Being - (220 reputation)Supreme Being - (220 reputation)Supreme Being - (220 reputation)Supreme Being - (220 reputation)Supreme Being - (220 reputation)Supreme Being - (220 reputation)Supreme Being - (220 reputation)Supreme Being - (220 reputation)Supreme Being - (220 reputation)

Group: Forum Members
Last Active: 2012-01-13 13:30:02
Posts: 34, Visits: 495
220
thanks,It's really helpful to this Scott.

Kind regards, ScottSmile

-----------------------
/Just do it


Similar Topics

Expand / Collapse

Reading This Topic

Expand / Collapse

Back To Top