PrefValue

Posts   
 
    
hommels
User
Posts: 23
Joined: 01-Jul-2005
# Posted on: 05-Jul-2005 19:48:31   

What is the equivalent code for Adapter model for

private EntityCollection _AppUserPrefs = new EntityCollection();

return _AppUserPrefs[index].PrefValue;

It says that PrefValue does not exist

jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 05-Jul-2005 20:37:48   

hommels wrote:

What is the equivalent code for Adapter model for

private EntityCollection _AppUserPrefs = new EntityCollection();

return _AppUserPrefs[index].PrefValue;

It says that PrefValue does not exist

_AppUserPrefs[index] needs to be cast to the entity you're looking for in order to gain typed access to the class members as the items are returned as IEntity2 objects. So:


private EntityCollection _AppUserPrefs = new EntityCollection();

return ((AppUserPrefsEntity)_AppUserPrefs[index]).PrefValue;

Hope that helps.

Jeff...

hommels
User
Posts: 23
Joined: 01-Jul-2005
# Posted on: 15-Jul-2005 20:18:16   

What reference do you need to cast this

return ((AppUserPrefsEntity)_AppUserPrefs[index]).PrefValue;

it says AppUserPrefsEntity reference cannot be found or missing.

is AppUserPrefsEntity a selfservicing entity?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 15-Jul-2005 20:28:33   

No, it's a type in your generated code project (database generic), please add a using <yournamespace>.EntityClasses; at the top of the file.

Frans Bouma | Lead developer LLBLGen Pro
hommels
User
Posts: 23
Joined: 01-Jul-2005
# Posted on: 15-Jul-2005 20:32:31   

I already had that reference, but as you can see from the previus post he said that i had to cast it and PrefValue does not exist in the Adapter model..

How do you rewrite this piece of code?

return _AppUserPrefs[index].PrefValue

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 15-Jul-2005 20:57:33   

hommels wrote:

I already had that reference, but as you can see from the previus post he said that i had to cast it and PrefValue does not exist in the Adapter model..

How do you rewrite this piece of code?

return _AppUserPrefs[index].PrefValue

Like Jeff explained, cast the entry in the collection to the type of the entity in the collection.

In verbose terms: AppUserPrefsEntity theEntity = (AppUserPrefsEntity)_AppUserPrefs[index]; return theEntity.PrefValue;

Frans Bouma | Lead developer LLBLGen Pro