Print Page | Close Window

Determine table name from type

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2012
Forum Discription: For .NET 4.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=4120
Printed Date: 24-Oct-2025 at 4:57pm


Topic: Determine table name from type
Posted By: murray.bryant
Subject: Determine table name from type
Date Posted: 21-Apr-2013 at 7:56pm
Hi 

I am trying to implement dynamic ESQL queries for performance reasons.

I need to work out what the table name is from the type.

All the references to this in the forum are from old devforce versions and I can't seem to get them to work

What is the best way to do this in 2012

thanks

Murray



Replies:
Posted By: kimj
Date Posted: 22-Apr-2013 at 1:29pm
ESQL queries actually use the entity set name, not the table name. The EntityMetadata for an entity has a DefaultEntitySetName property you can use for this.

Storage information, like table names, is not available from DevForce.


Posted By: murray.bryant
Date Posted: 22-Apr-2013 at 4:43pm
Thanks for the response

Do you know how to get the EntityMetadata from the entityType?





Posted By: kimj
Date Posted: 22-Apr-2013 at 4:46pm
Yep. See http://drc.ideablade.com/devforce-2012/bin/view/Documentation/model-examine - http://drc.ideablade.com/devforce-2012/bin/view/Documentation/model-examine .


Posted By: murray.bryant
Date Posted: 22-Apr-2013 at 4:56pm
Ah thanks for that

I am trying to return a distinct collection of column values ( ie Ienumerable<String>) from a table

Is it possible to do this with Esql? Your documentation does not cover this case and I am getting errors about not returning a valid entity

 var queryString = String.Format("Select DISTINCT [{0}] from {1}", mappingField.EntityFieldName, metadata.DefaultEntitySetName);

  var query = new PassthruEsqlQuery(entityType, queryString);



Posted By: murray.bryant
Date Posted: 22-Apr-2013 at 5:09pm
I ended up going with dynamic linq

  var rootquery = IdeaBlade.EntityModel.EntityQuery.Create(entity.EntityType, _importRepository.Manager);
                    var selector = new ProjectionSelector(mappingField.EntityFieldName);

                    var query = rootquery.Select(selector).Distinct();

                    var results = query.Execute();





Posted By: kimj
Date Posted: 22-Apr-2013 at 6:20pm
We don't support anonymous projections with ESQL, which is what your PassthruEsqlQuery would have returned. So, as you found, dynamic LINQ is the way to go here.



Print Page | Close Window