Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Bugs & Issues> EntityFieldFactory.Create bug?
 

Pages: 1
Bugs & Issues
EntityFieldFactory.Create bug?
Page:1/1 

  Print all messages in this thread  
Poster Message
TomV
User



Location:
Belgium
Joined on:
31-Jan-2008 14:22:10
Posted:
76 posts
# Posted on: 29-Aug-2008 18:08:10.  
Hi,

I think there's a bug in the EntityFieldFactory.Create(string objectName, string fieldName) method. Things work just fine when I use this method for normal entities.

But today I struggled quite some hours to identify this "bug". I use inheritance (based on the discriminator column). At runtime I try to identify a field of an inherited entity, to use for my dynamic ConcurrencyPredicateFactory. (A timestamp field called Version).

The line of code I use is the following:

Code:

EntityField2 timestampField =
             (EntityField2)EntityFieldFactory.Create(entity.GetType().Name, TIME_STAMP_FIELD_NAME)

Where TIME_STAMP_FIELD_NAME is a constant that holds the value "Version"


This line works just fine for alle normal entities or the base entity. But for the derived classed, this line of code produces the following error:

The field 'Version' isn't known in the element 'Em3xxEntity'
Parameternaam: elementFieldName


This means that in following example the first 2 would be ok, but the third one fails (because Em3xx is derived from Device)

Code:

         EntityField2 timestampField = (EntityField2)EntityFieldFactory.Create("FuelEntity", "Version");

         EntityField2 timestampField2 = (EntityField2)EntityFieldFactory.Create("Device", "Version");

         EntityField2 timestampField3 = (EntityField2)EntityFieldFactory.Create("Em3xx", "Version");


This is the end of the stacktrace...
Code:

bij SD.LLBLGen.Pro.ORMSupportClasses.FieldInfoProviderBase.GetFieldInfo(String elementName, String elementFieldName)
bij EMGroup.Galantis.BL.Core.FactoryClasses.EntityFieldFactory.Create(String objectName, String fieldName) in


Can you please help me out for this one?

Kind regards,
TomV
Life goes fast, it must be riding a Ducati!  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8099 posts
# Posted on: 30-Aug-2008 07:28:30.  
Hi Tom, I think, this is by design. However I think this workaround should work:

Code:
EntityField2 timestampField = (EntityField2)EntityFieldFactory.Create(
     entity.Fields[TIME_STAMP_FIELD_NAME].ContainingObjectName,
     TIME_STAMP_FIELD_NAME);


As you see, ContainingObjectName is useful where the entity belongs to an inheritance, this also work if the entity doesn't.


David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37812 posts
# Posted on: 30-Aug-2008 10:53:51.  
What's the llblgen pro version, build date etc. ?

Is the version field mapped in the derived entity or in the supertype/root?
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
TomV
User



Location:
Belgium
Joined on:
31-Jan-2008 14:22:10
Posted:
76 posts
# Posted on: 01-Sep-2008 08:44:49.  
Otis wrote:
What's the llblgen pro version, build date etc. ?

Is the version field mapped in the derived entity or in the supertype/root?


Hi Otis, sorry I always forget to post this..

- It's Version 2.5 Final (December 5th, 2007)
- The version field is mapped on the root type, so it's available as an inherited field.


Hi Daelmo,
your work around seems to work.


Although I think it should have worked the way I used the code.

Kind regards,
TomV


Life goes fast, it must be riding a Ducati!  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14569 posts
# Posted on: 01-Sep-2008 10:47:07.  
You are using an old runtime library version, would you please try using the latest available version, just to be sure it has nothing to do with the old version.
  Top
TomV
User



Location:
Belgium
Joined on:
31-Jan-2008 14:22:10
Posted:
76 posts
# Posted on: 01-Sep-2008 11:06:55.  
Ok Walaa,
I was still running the version I downloaded when we bought our license. I will download the version 2.6 and let you know the result...

Kind regards,
TomV


Life goes fast, it must be riding a Ducati!  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14569 posts
# Posted on: 01-Sep-2008 11:36:06.  
You can also download the latest release of v.2.5
  Top
TomV
User



Location:
Belgium
Joined on:
31-Jan-2008 14:22:10
Posted:
76 posts
# Posted on: 01-Sep-2008 11:42:03.  
Too late, I already converted my project to 2.6... Not a bad thing at all...

It took me some time, adding templates, plugins, parameters in config files, but things build again...

- The problem still exists in version 2.6 (August 18th, 2008 )

Regards,
TomV


Life goes fast, it must be riding a Ducati!  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37812 posts
# Posted on: 01-Sep-2008 18:05:39.  
Fixed in next build. Although the code you use isn't really maintainable. Consider a utility routine which produces an entity based on EntityType and obtain the field from there, also using an entity field index, because names are not compile time checked of course.
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
TomV
User



Location:
Belgium
Joined on:
31-Jan-2008 14:22:10
Posted:
76 posts
# Posted on: 01-Sep-2008 18:14:01.  
Otis wrote:
Fixed in next build. Although the code you use isn't really maintainable. Consider a utility routine which produces an entity based on EntityType and obtain the field from there, also using an entity field index, because names are not compile time checked of course.


Hi Otis,

thanks for the answer.

I only use this approach for my concurrency handling. All my tables their last column is a timestamp (name: Version) column on SQL Server. I created a plugin + template for LLBLGenPro which makes sure that all my entities implement the interface IIdAndVersion.

This way I can use the constant TIME_STAMP_FIELD_NAME safely. But this is the only place, at all other places I use the available enums or field index.

Again, thanks for your fast help guys!

Kind regards,
TomV


Life goes fast, it must be riding a Ducati!  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.