Schema Info in Generated Code

Posts   
 
    
MPW
User
Posts: 27
Joined: 28-Aug-2007
# Posted on: 22-May-2008 15:24:44   

I'm currently writing a GUI query generator to produce Dynamic Lists and need to get the fields and datatypes for SQL views which are mapped as entities. I've found various enums for fields but no datatype info. What is the best way to get fieldnames, datatypes, keys and relations from LLBGEN.

Thanks Mark

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 22-May-2008 15:52:34   

Please check the EntityField class properties in the Refernce Manual.

MPW
User
Posts: 27
Joined: 28-Aug-2007
# Posted on: 22-May-2008 22:16:45   

OK so how do you generate an EntityField for a field in a view when you have the viewname and fieldname as strings (from GUI comboboxes); so you can use it in code to generate a dynamic list.

ResultsetFields fields = new ResultsetFields(1); fields.DefineField(????,0);

It took me a half an hour to do all this in straight SQL with code like DataTable views = con.GetSchema(SqlClientMetaDataCollectionNames.Views);

and

SqlCommand cmd = new SqlCommand("select * from " + Viewname, con); SqlDataReader r = cmd.ExecuteReader(CommandBehavior.SchemaOnly);

but the generated code has so much baggage, I get lost, casts here there and everywhere confused It's been a hard day cry

MPW
User
Posts: 27
Joined: 28-Aug-2007
# Posted on: 23-May-2008 00:41:07   

My bad flushed

ResultsetFields fields = new ResultsetFields(1); EntityField ef = (EntityField)EntityFieldFactory.Create("Person.ViewEntity","Surname"); fields.DefineField(ef, 0);

I'll read more slowly!