New Posts New Posts RSS Feed: Determine table name from type
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Determine table name from type

 Post Reply Post Reply
Author
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Topic: Determine table name from type
    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.
Back to Top
murray.bryant View Drop Down
Groupie
Groupie


Joined: 11-Jan-2012
Location: Australia
Posts: 44
Post Options Post Options   Quote murray.bryant Quote  Post ReplyReply Direct Link To This Post 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();



Back to Top
murray.bryant View Drop Down
Groupie
Groupie


Joined: 11-Jan-2012
Location: Australia
Posts: 44
Post Options Post Options   Quote murray.bryant Quote  Post ReplyReply Direct Link To This Post 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);

Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 22-Apr-2013 at 4:46pm
Back to Top
murray.bryant View Drop Down
Groupie
Groupie


Joined: 11-Jan-2012
Location: Australia
Posts: 44
Post Options Post Options   Quote murray.bryant Quote  Post ReplyReply Direct Link To This Post Posted: 22-Apr-2013 at 4:43pm
Thanks for the response

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



Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
murray.bryant View Drop Down
Groupie
Groupie


Joined: 11-Jan-2012
Location: Australia
Posts: 44
Post Options Post Options   Quote murray.bryant Quote  Post ReplyReply Direct Link To This Post 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


Edited by murray.bryant - 21-Apr-2013 at 8:12pm
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down