Query Field Names for Table.

Posts   
 
    
lochiano
User
Posts: 3
Joined: 21-Aug-2017
# Posted on: 21-Aug-2017 00:32:11   

Sorry if this is an 'obvious' question, but I cannot find it in your documentation.

I need to generate a list of the column names (and other properties such as type) from any table.

Ideally, it would be great to both discover all of the visible tables in a database and then walk each table to gather the column specific information.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 21-Aug-2017 06:13:50   

Hi lochiano,

Do you want to do this in your own .net code? Or, Do you want to do this in the LLBLGen Designer? Do you want to generate some code that already contain this? What is your target framework (LLBLGen Framework, EntityFramework, NHibernate)?

In general, please explain your scenario so we can guide you in the best direction possible. ( http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7722 )

David Elizondo | LLBLGen Support Team
lochiano
User
Posts: 3
Joined: 21-Aug-2017
# Posted on: 21-Aug-2017 19:49:48   

I would like to do this in my .Net Code. The target is SQL Server. The development project will involve the 'discovery' of databases that are not hard-coded into the application.

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 22-Aug-2017 03:38:51   

Your scenario is still vague. Please elaborate more into the business scenario and try to answer David's questions precisely and on more details. Especially the framework, whether you want this info generated in code or you want to write some APIs that will receive an entity or entityType and return such info.

lochiano
User
Posts: 3
Joined: 21-Aug-2017
# Posted on: 22-Aug-2017 14:42:18   

I am just fine with writing code to loop through all of the tables and gather all of the field information. What is missing is where this information may be found. Lets assume that the framework is LLBLGen Framework.

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 22-Aug-2017 20:29:50   

You can loop the EntityType and get all fields for each enittyType

var fields = EntityFieldsFactory.CreateEntityFieldsObject(Northwind.EntityType.CustomerEntity);

Then you need to derive from DataAccessAdapter and create your own method that accepts a field and call GetFieldPersistenceInfo on the adapter (since it's protected), and return the FieldPersistenceInfo for each field passed.

check this for a hint: http://llblgen.com/tinyforum/Messages.aspx?ThreadID=20908