|
|
|
Forum Member
      
Group: Forum Members
Last Login: 2011-12-15 02:08:37
Posts: 35,
Visits: 260
|
|
Like title,If I know the class name and id (not ExternalId,is really id in database);How can get this object?
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)
thank you !
|
|
|
|
|
Supreme Being
      
Group: Administrators
Last Login: 2010-11-30 12:17:13
Posts: 1 230,
Visits: 1 382
|
|
To get the object if you have the primary key and classname:
object key = 1234;
IObject obj = EcoSpace.CacheContent.GetObject(key, "MyClass");
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).
When you transform from an ExternalId to an object:
string id = "123!123123";
IObject obj2 = EcoSpace.ExternalIds.ObjectForId(id);
the object will be automaticlly fetched. The ExternalId normally consists of index of the type in the runtime model and the primary key.
string[] parts = id.Split('!');
string classname = EcoSpace.TypeSystem.AllClasses[int.Parse(parts[0])].Name;
int key2 = int.Parse(parts[1]);
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.
/Jonas Hogstrom [CapableObjects]
|
|
|
|
|
Forum Newbie
      
Group: Forum Members
Last Login: 2010-08-27 16:54:01
Posts: 1,
Visits: 9
|
|
Hi,
I Have the same problem in ECO3 and BDS2006
I Have a SQLQuery which give me
ECO_TYPE, ECO_ID, Attr1, Attr2
43, 2540, C001, Customer1
43, 2780, C002, Customer2
In my app, if I use GetIDForObject, the result is 65:2540 and 65:2780
How can I load these objects in the ecospace (I Know the good classname)?
I have download your app sample (customfetch), but in my version, ICacheContentService doesn't exist.
Thanks
|
|
|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2012-02-01 10:36:37
Posts: 101,
Visits: 751
|
|
|
|
|