Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> Name of database field mapped on entity field
 

Pages: 1
LLBLGen Pro Runtime Framework
Name of database field mapped on entity field
Page:1/1 

  Print all messages in this thread  
Poster Message
omar
User



Location:
Salmiya, Kuwait
Joined on:
15-Oct-2004 15:44:57
Posted:
569 posts
# Posted on: 10-Oct-2009 18:01:12.  
Is there a way to get at runtime the name of the db field mapped on the entity field ??

EDIT:

CustomerEntity e = new CustomerEntity();

e.Fields[0].Name <== this gives the entity's field name NOT the name of the source DB field
We don't know who we are until we see what we can do  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37797 posts
# Posted on: 11-Oct-2009 11:16:48.  
In selfservicing, it's in the field, in adapter, you need to obtain the fieldpersistence info, what do you use, adapter or selfservicing?

Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
omar
User



Location:
Salmiya, Kuwait
Joined on:
15-Oct-2004 15:44:57
Posted:
569 posts
# Posted on: 11-Oct-2009 14:28:12.  
I am using Adapter (ofcourse Regular Smiley)... I will check this fieldpersistence object but any tips are always welcomed Regular Smiley
We don't know who we are until we see what we can do  Top
omar
User



Location:
Salmiya, Kuwait
Joined on:
15-Oct-2004 15:44:57
Posted:
569 posts
# Posted on: 11-Oct-2009 16:02:05.  
I found the following in DADBSpecific

Code:
    internal class PersistenceInfoProviderCore : PersistenceInfoProviderBase
    {
        /// <summary>Initializes a new instance of the <see cref="PersistenceInfoProviderCore"/> class.</summary>
        internal PersistenceInfoProviderCore()
        {
            Init();
        }

        /// <summary>Method which initializes the internal datastores with the structure of hierarchical types.</summary>
        private void Init()
        {
            base.InitClass((1 + 0));
            InitUidictionaryEntityMappings();

        }


        /// <summary>Inits UidictionaryEntity's mappings</summary>
        private void InitUidictionaryEntityMappings()
        {
            base.AddElementMapping( "UidictionaryEntity", "winUI", @"Default", "UIDictionary", 3 );
            base.AddElementFieldMapping( "UidictionaryEntity", "SourceFormName1", "SourceFormName", false, (int)OleDbType.VarWChar, 75, 0, 0, false, "", null, typeof(System.String), 0 );
            base.AddElementFieldMapping( "UidictionaryEntity", "EntityName1", "EntityName", false, (int)OleDbType.VarWChar, 75, 0, 0, false, "", null, typeof(System.String), 1 );
            base.AddElementFieldMapping( "UidictionaryEntity", "TargetFormName1", "TargetFormName", true, (int)OleDbType.VarWChar, 75, 0, 0, false, "", null, typeof(System.String), 2 );
        }

    }


In the LLBL project file I changed the property name of the field sourceFormName to sourceFormName1 so to track where to find the mapping

Is it true to assume that in the following code:

Code:
base.AddElementFieldMapping( "UidictionaryEntity", "SourceFormName1", "SourceFormName", false, (int)OleDbType.VarWChar, 75, 0, 0, false, "", null, typeof(System.String), 0 );

"SourceFormName1" is the entity field's property name and "SourceFormName" is the name of the DB table field mapped on that entity field?

If that is truly the case, how can I obtain this info? If I try the following
Code:
var x = FieldInfoProviderSingleton.GetInstance().GetFieldInfo("UidictionaryEntity", (int)fieldIndex);


(where field index is the index of the field I need) and inspect the properties of x, which property will give me "SourceFormName" instead of "SourceFormName1" ??


We don't know who we are until we see what we can do  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8098 posts
# Posted on: 11-Oct-2009 21:27:30.  
Here is the snippet to figure out the source column name for a given IEntityField2: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=12530&StartAtMessage=0&#69571
David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
omar
User



Location:
Salmiya, Kuwait
Joined on:
15-Oct-2004 15:44:57
Posted:
569 posts
# Posted on: 11-Oct-2009 23:15:03.  
Right on the money.. works like a charm... Thank you daelmo

We don't know who we are until we see what we can do  Top
mohamed
User



Location:
Salmia, kuwait
Joined on:
10-Mar-2008 19:55:21
Posted:
136 posts
# Posted on: 12-Oct-2009 17:37:12.  
Hello,

Is it possible to get the database Table name of an Entity2 ?

Like CustomerEntity ==> Customer <==this is table name from Database
  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14569 posts
# Posted on: 12-Oct-2009 17:41:47.  
Exactly the same as above but using SourceObjectName property instead of SourceColumnName.

  Top
mohamed
User



Location:
Salmia, kuwait
Joined on:
10-Mar-2008 19:55:21
Posted:
136 posts
# Posted on: 12-Oct-2009 17:46:45.  
Walaa.. thanks for reply, but this is the table name of field

what i want, Passing entity2 and get its table name

  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8098 posts
# Posted on: 13-Oct-2009 04:00:12.  
Here is an example:
Code:
namespace <YourRootNamespace>.DatabaseSpecific
{
    public partial class DataAccessAdapter
    {    
    
        public string GetSourceTableName(IEntity2 entity)
        {
            return this.GetFieldPersistenceInfos(entity)[0].SourceObjectName;
        }        

    }
}


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



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14569 posts
# Posted on: 13-Oct-2009 09:35:55.  
To elaborate more on this:
An entity can have fields mapped to more tha one database table, as in the case of inheritance, that's why the Field or FieldPersistenceInfo is the structure/class holding the mapped table name.
  Top
omar
User



Location:
Salmiya, Kuwait
Joined on:
15-Oct-2004 15:44:57
Posted:
569 posts
# Posted on: 13-Oct-2009 09:48:02.  
so Walaa.. ignoring the inheritance angle and assuming all my entities are mapped one-to-one to tables/views, I can safely assume all the entity fields have the same DB table mapping

We don't know who we are until we see what we can do  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14569 posts
# Posted on: 13-Oct-2009 10:13:55.  
Sure.
  Top
omar
User



Location:
Salmiya, Kuwait
Joined on:
15-Oct-2004 15:44:57
Posted:
569 posts
# Posted on: 13-Oct-2009 10:19:53.  
Thank Walaa and thank you all for the great input..this forum continues to be as useful as ever

We don't know who we are until we see what we can do  Top
AlbertK
User



Location:

Joined on:
23-Dec-2009 17:51:37
Posted:
44 posts
# Posted on: 27-Nov-2012 18:29:52.  
I have a question related to this thread. I have entity that is a subtype. How can I retrieve source table name at run time? GetFieldPersistenceInfos() returns empty array.
I see generated code calling this.AddElementMapping() on the entity that is a subtype, I just don't know how to get to the table name. I'm using version 3.1.

Thank you.
  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14569 posts
# Posted on: 27-Nov-2012 19:07:10.  
Please open a new thread for your question.
(hint: check forum guidelines)

Thanks.


  Top
Pages: 1  


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

Version: 2.1.12172008 Final.