﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>CapableObjects Forums / ECO / General discussions  / How to get object from class name and ID? / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>CapableObjects Forums</description><link>http://www.capableobjects.com/apps/InstantForum414/</link><webMaster>forums@capableobjects.com</webMaster><lastBuildDate>Wed, 08 Feb 2012 22:34:05 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: How to get object from class name and ID?</title><link>http://www.capableobjects.com/apps/InstantForum414/Topic5104-4-1.aspx</link><description>In ECO3 there is no ICacheContentService. If upgrading Eco is not an option, try EcoSqlCondition [url]http://ecosqlcondition.codeplex.com/releases/view/29054[/url]&lt;br&gt;The first version works with Eco4, but with minor changes it should run with Eco3.</description><pubDate>Fri, 27 Aug 2010 09:40:25 GMT</pubDate><dc:creator>Pawel</dc:creator></item><item><title>RE: How to get object from class name and ID?</title><link>http://www.capableobjects.com/apps/InstantForum414/Topic5104-4-1.aspx</link><description>Hi,&lt;br&gt;&lt;br&gt;I Have the same problem in ECO3 and BDS2006 &lt;br&gt;I Have a SQLQuery which give me &lt;br&gt;&lt;br&gt;ECO_TYPE, ECO_ID, Attr1, Attr2&lt;br&gt;43,    2540,    C001, Customer1&lt;br&gt;43,    2780,    C002, Customer2&lt;br&gt;&lt;br&gt;In my app, if I use GetIDForObject, the result is 65:2540 and 65:2780&lt;br&gt;&lt;br&gt;How can I load these objects in the ecospace  (I Know the good classname)?&lt;br&gt;&lt;br&gt;&lt;br&gt;I have download your app sample (customfetch), but in my version, ICacheContentService  doesn't exist.&lt;br&gt;&lt;br&gt;Thanks&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</description><pubDate>Thu, 26 Aug 2010 18:59:08 GMT</pubDate><dc:creator>ramdevteam</dc:creator></item><item><title>RE: How to get object from class name and ID?</title><link>http://www.capableobjects.com/apps/InstantForum414/Topic5104-4-1.aspx</link><description>To get the object if you have the primary key and classname:&lt;br&gt;&lt;br&gt; [code]     object key = 1234;&lt;br&gt;      IObject obj = EcoSpace.CacheContent.GetObject(key, "MyClass");&lt;br&gt;[/code]&lt;br&gt;The purpose of the ICacheContentService is to be able to stuff things into the ecospace objectcache as if they came from the database. If you have some scenario where the performance in ECO is not sufficient and a custom crafted SQL can load alot of data very quickly, you can load it directly from the db and stuff it into the cache. A sideeffect is that it allows you to convert a primary key to the corresponding object (without loading it from the db).&lt;br&gt;&lt;br&gt;When  you transform from an ExternalId to an object:&lt;br&gt;&lt;br&gt;[code]      string id = "123!123123";&lt;br&gt;      IObject obj2 = EcoSpace.ExternalIds.ObjectForId(id);&lt;br&gt;[/code]&lt;br&gt;the object will be automaticlly fetched. The ExternalId normally consists of index of the type in the runtime model and the primary key. &lt;br&gt;&lt;br&gt;&lt;br&gt;[code]      string[] parts = id.Split('!');&lt;br&gt;      string classname = EcoSpace.TypeSystem.AllClasses[int.Parse(parts[0])].Name;&lt;br&gt;      int key2 = int.Parse(parts[1]);&lt;br&gt;[/code]&lt;br&gt;&lt;br&gt;but this only work for the simple case where the object is already persisted in the database and the key is an int32 and you are using the default externalid mechanism. The only safe way to transform an externalid back to an object is to use the same ExternalId service implementation that generated it.&lt;br&gt;</description><pubDate>Tue, 13 Apr 2010 09:39:13 GMT</pubDate><dc:creator>Jonas Hogstrom</dc:creator></item><item><title>How to get object from class name and ID?</title><link>http://www.capableobjects.com/apps/InstantForum414/Topic5104-4-1.aspx</link><description>Like title,If I know the class name and id (not ExternalId,is really id in database);How can get this object?&lt;br&gt;Another question,if I have the ExternalId,how to get the class name and id. (not to load object,then get the object type name)&lt;br&gt;thank you !&lt;br&gt;</description><pubDate>Fri, 02 Apr 2010 00:53:58 GMT</pubDate><dc:creator>wangwei.njcn</dc:creator></item></channel></rss>
