IRealtionPredicateBucket.Relations.Add Won't Take IEntityField2

Posts   
 
    
NickD
User
Posts: 224
Joined: 31-Jan-2005
# Posted on: 10-May-2005 23:24:28   

I had set up my IRelationPredicateBucket var and was going to do this:

buketVar.Relations.Add(new EntityRelation(EntityFieldFactory.Create(EntityAFieldIndex.ColumnA), EntityFieldFactory.Create(EntityBFieldIndex.ColumnA),RelationType.OneToMany);

...but when I tried to compile, it told me that IEntityField2 could not convert to IEntityField. I was surprised. I got around it simply by creating an IEntityRelation var and doing an AddEntityFieldPair to it, but that seems like an extra step. I'm sure you lay this out in the docs some where but curious why the Relations.Add only expects IEntityField and not IEntityField2?

jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 11-May-2005 00:05:58   

NickD wrote:

I had set up my IRelationPredicateBucket var and was going to do this:

buketVar.Relations.Add(new EntityRelation(EntityFieldFactory.Create(EntityAFieldIndex.ColumnA), EntityFieldFactory.Create(EntityBFieldIndex.ColumnA),RelationType.OneToMany);

...but when I tried to compile, it told me that IEntityField2 could not convert to IEntityField. I was surprised. I got around it simply by creating an IEntityRelation var and doing an AddEntityFieldPair to it, but that seems like an extra step. I'm sure you lay this out in the docs some where but curious why the Relations.Add only expects IEntityField and not IEntityField2?

Hi, there. It sounds like you're using the wrong EntityFieldFactory. Do you perhaps have a reference to both a Self-Servicing DAL as well as an Adapter DAL? If so, make sure you're using the Adapter's EntityFieldFactory.

Also, it looks like you're creating a custom relationship? Is that what you're intending to do, or are you trying to add an existing relationship set up in the DB? If you don't need a custom relationship, you should be able to use


bucketVar.Relations.Add(EntityAEntity.Relations.EntityBUsingEntityBID);

Jeff...

NickD
User
Posts: 224
Joined: 31-Jan-2005
# Posted on: 11-May-2005 00:20:37   

jeffreygg wrote:

NickD wrote:

I had set up my IRelationPredicateBucket var and was going to do this:

buketVar.Relations.Add(new EntityRelation(EntityFieldFactory.Create(EntityAFieldIndex.ColumnA), EntityFieldFactory.Create(EntityBFieldIndex.ColumnA),RelationType.OneToMany);

...but when I tried to compile, it told me that IEntityField2 could not convert to IEntityField. I was surprised. I got around it simply by creating an IEntityRelation var and doing an AddEntityFieldPair to it, but that seems like an extra step. I'm sure you lay this out in the docs some where but curious why the Relations.Add only expects IEntityField and not IEntityField2?

Hi, there. It sounds like you're using the wrong EntityFieldFactory. Do you perhaps have a reference to both a Self-Servicing DAL as well as an Adapter DAL? If so, make sure you're using the Adapter's EntityFieldFactory.

Also, it looks like you're creating a custom relationship? Is that what you're intending to do, or are you trying to add an existing relationship set up in the DB? If you don't need a custom relationship, you should be able to use


bucketVar.Relations.Add(EntityAEntity.Relations.EntityBUsingEntityBID);

Jeff...

I am only using the Adapter's DAL and yes, I am trying to add a custom relationship. One thing I have become quite accostomed to is LLBLGen exposing all the holes in my datamodel confused . This one is a minor foreign key relationship so I'm just going to add it here.

However, I too understand what you are getting at, but I'm pretty sure I'm using the right factory.

jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 11-May-2005 01:15:23   

NickD wrote:

jeffreygg wrote:

NickD wrote:

I had set up my IRelationPredicateBucket var and was going to do this:

buketVar.Relations.Add(new EntityRelation(EntityFieldFactory.Create(EntityAFieldIndex.ColumnA), EntityFieldFactory.Create(EntityBFieldIndex.ColumnA),RelationType.OneToMany);

...but when I tried to compile, it told me that IEntityField2 could not convert to IEntityField. I was surprised. I got around it simply by creating an IEntityRelation var and doing an AddEntityFieldPair to it, but that seems like an extra step. I'm sure you lay this out in the docs some where but curious why the Relations.Add only expects IEntityField and not IEntityField2?

Hi, there. It sounds like you're using the wrong EntityFieldFactory. Do you perhaps have a reference to both a Self-Servicing DAL as well as an Adapter DAL? If so, make sure you're using the Adapter's EntityFieldFactory.

Also, it looks like you're creating a custom relationship? Is that what you're intending to do, or are you trying to add an existing relationship set up in the DB? If you don't need a custom relationship, you should be able to use


bucketVar.Relations.Add(EntityAEntity.Relations.EntityBUsingEntityBID);

Jeff...

I am only using the Adapter's DAL and yes, I am trying to add a custom relationship. One thing I have become quite accostomed to is LLBLGen exposing all the holes in my datamodel confused . This one is a minor foreign key relationship so I'm just going to add it here.

However, I too understand what you are getting at, but I'm pretty sure I'm using the right factory.

Ah, I see the problem. It looks like Frans omitted an overload for the constructor for EntityRelation that accepts IEntityField2 objects. The overload you're using only accepts IEntityField objects. So, you're using the right factory, but the overload only accepts Self-Servicing IEntityField objects.

Until he's able to make the addition you'll need to use the AddEntityFieldPair method.

Jeff...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 11-May-2005 09:33:53   

Yes the constructor of EntityRelation is selfservicing only, as it's not used anymore in that form, as you can see in the generated code.

As Jeff has described, use AddEntityFieldPair. It's 1 extra line of code wink . I'll file it as a bug that the constructor isn't available for adapter.

Frans Bouma | Lead developer LLBLGen Pro
NickD
User
Posts: 224
Joined: 31-Jan-2005
# Posted on: 11-May-2005 16:10:25   

Otis wrote:

Yes the constructor of EntityRelation is selfservicing only, as it's not used anymore in that form, as you can see in the generated code.

As Jeff has described, use AddEntityFieldPair. It's 1 extra line of code wink . I'll file it as a bug that the constructor isn't available for adapter.

Great! No worries though, like you say, the AddEntityFieldPair is just as easy to use.