﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>CapableObjects forum » ECO » General discussions  » Class methods in ECO</title><generator>InstantForum.NET 2012-1</generator><description>CapableObjects forum</description><link>http://www.capableobjects.com/apps/InstantForum414/</link><webMaster>CapableObjects forum</webMaster><lastBuildDate>Fri, 18 May 2012 04:19:48 GMT</lastBuildDate><ttl>20</ttl><item><title>Class methods in ECO</title><link>http://www.capableobjects.com/apps/InstantForum414/FindPost2231.aspx</link><description>Hello everyone!&lt;br&gt;I am very new to ECO. Could someone please explain me about the class methods concept in ECO. For example, in ECO4 you can create a method in your model for some class, then in the Body you can specify some actions using EAL, generate the code and everything should work.&lt;br&gt;&lt;br&gt;As an problematic example here is a part of the model (modeling the growth of a plant depending on a weather conditions):&lt;br&gt;    PlantGrowth (Plant) 1 --- 0..* (Weather) Weather&lt;br&gt;In the Weather class I want to have a method GetWeather(). It should take PlantGrowth.Date and assign it's value to self.Date. Then I need to retrieve some data from external database using the same Date as a WHERE clause. Where should I set the connection and assign the retrieved values to the Weather object? &lt;br&gt;I have managed to do that in form's code using CurrencyManagerHandle, knowing both the current PlantGrowth object and Weather object and working with their attributes. But how can I implement that from the model side?</description><pubDate>Mon, 09 Feb 2009 00:09:20 GMT</pubDate><dc:creator>saniokkk</dc:creator></item><item><title>RE: Class methods in ECO</title><link>http://www.capableobjects.com/apps/InstantForum414/FindPost2243.aspx</link><description>To be able get this kind of informatoin when coding in the model, I suggest you register a service in your ecospace.&lt;br&gt;&lt;br&gt;It would look something like this:&lt;br&gt;&lt;br&gt;in the ecospace constructor:&lt;br&gt;  RegisterEcoService(typeof(IMyService), new MyService(myConnectionString));&lt;br&gt;&lt;br&gt;Where IMyService is the interface you want to be able to use in your domain classes, MyService is a class that implements this interface and myConnectoinString is just an arbitrary parameter to this class (for example the connectoin string to the external database).&lt;br&gt;&lt;br&gt;In your domain claass you might write something like:&lt;br&gt;&lt;br&gt;IMyService serv = AsIObject().ServiceProvider.GetEcoService(typeof(IMyService)) as IMyService;&lt;br&gt;&lt;br&gt;Weather w = serv.GetWeatherByDate(aDate);&lt;br&gt;&lt;br&gt;// do whatever&lt;br&gt;&lt;br&gt;In ECO5, there are some new generic overloads that reduces the need for casting in the code above, but this code should work in both ECO4 and 5.</description><pubDate>Mon, 09 Feb 2009 00:09:20 GMT</pubDate><dc:creator>Jonas Hogstrom</dc:creator></item></channel></rss>
