New Posts New Posts RSS Feed: Query Dynamic
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Query Dynamic

 Post Reply Post Reply
Author
giotis View Drop Down
Groupie
Groupie
Avatar

Joined: 26-Apr-2012
Location: Greece
Posts: 53
Post Options Post Options   Quote giotis Quote  Post ReplyReply Direct Link To This Post Topic: Query Dynamic
    Posted: 21-Jun-2012 at 2:45pm
what is the best method to implement a LINQ query in runtime, without limiting functionality of Cocktail.

Something like this :

string str= "EntityManager.StaffingResources
                             .Where(r => r.Id == (Guid) keyValues[0])
                             .Include(r => r.Addresses)
                             .Include(r => r.PhoneNumbers)"


IEntityQuery  query =
FromStringToEntityQuery(TempHireEntities, str);

Is this possible ?


Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 21-Jun-2012 at 3:44pm
That would be using the dynamic LINQ feature in DevForce. It's not quite as simple as turning a string into a query, but it's fully dynamic and lets you dynamically compose a query at runtime.
 
Back to Top
giotis View Drop Down
Groupie
Groupie
Avatar

Joined: 26-Apr-2012
Location: Greece
Posts: 53
Post Options Post Options   Quote giotis Quote  Post ReplyReply Direct Link To This Post Posted: 21-Jun-2012 at 4:50pm
The only reason to create queries on the fly  is only when you need to join tables without a common key or something else.
The
creation of dynamic queries by the DefForce
technique is quite difficult since I read and probably I will come
to the
ESQL
technique only when necessary.

I want to use it only for viewing. Is there any specific reason that we are forbidden to use this ?

there is any sample  - example ?

Edited by giotis - 21-Jun-2012 at 4:51pm
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 21-Jun-2012 at 5:08pm
I'm not following what you are saying. Joining tables without a common key is not a reason to create queries on the fly. As long as two entities have one or more type compatible properties you can join them statically using the join operator.
LINQ is by definition a strongly typed and static language integrated query language. That means you need to know at design time what your query is going to be and what the types are that you are querying. If you don't know that, then you are in the realm of needing to dynamically build queries at runtime. ESQL and LINQ are two different things.
 
.NET doesn't provide dyanamic LINQ out of the box, so DevForce adds this functionality. I'm not sure what you mean by forbidden to use this. Forbidden to use what?
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down