Print Page | Close Window

What is the Equivalent of DynamicEntity in new DevForce

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1912
Printed Date: 30-Apr-2025 at 4:18pm


Topic: What is the Equivalent of DynamicEntity in new DevForce
Posted By: *Calsy
Subject: What is the Equivalent of DynamicEntity in new DevForce
Date Posted: 23-Jun-2010 at 10:01pm
Hi All, In DevForce classic we were able to create a passthrurdbqry, pump an sql string into the passthrurdbqry and have it return as an entitylist(Of DynamicEntity). Just wondering how we do the equivalent in the new version of DevForce?
 
I know there is the PassthruEsqlQuery but you dont feed it a raw sql string (requires entity sql) and it has to be returned as a type (if im wrong im sorry, blonde moment). Im hoping (which we did in classic) that I can just go "Select * From BlahTable" and return all the records accordingly. 
 
It doesnt have to be silverlight specific because it will be executed at the server.
 
Thanks



Replies:
Posted By: GregD
Date Posted: 24-Jun-2010 at 6:22pm
DevForce 2010 doesn't talk directly to back-end databases: it talks to EF, and EF really wants your code to be independent of the back-end database. So EF lets you talk to it in LINQ and in ESQL.

ESQL is mostly useful for special situations where you need to compose a query as a text string, so let's talk about what you can do with LINQ. You can query against any entity defined in the EF model (and mapped there to a back-end table), returning arbitrary subsets of the entity's properties. You can also do even more interesting things like the following:

var q = _em1.Employees.Select(e => new { e.LastName, e.OrderSummaries });


The above, when exercised, will return an IEnumerable<a'>, where a' is an anonymous type. This particular anonymous type has two properties: a string and a RelatedEntityList<OrderSummary>.

DevForce also lets you query against Plain Old C Objects (POCOs). You create a server-side class with a method that returns an IEnumerable<Foo>, where a Foo is your plain old C object. This is documented today in the Business Object Persistence - Advanced document, in a section named "POCO Support in DevForce"; in the next release of DevForce it will be a stand-alone document named "POCO Support in DevForce".

What you cannot do is to use EF or DevForce to query against back-end database tables that are neither part of your EF model nor accessed by one of your server-side methods that returns POCOs.


Posted By: *Calsy
Date Posted: 24-Jun-2010 at 6:37pm

Hi Greg, Thanks for the reply.

Is there anyway than to pull data from a table/view at runtime that the EF doesnt have any previous knowledge of? i.e. At runtime the customer wants to create report that pulls back a certain set of data. We create the view in the database. Can we than somehow retrieve data from that view without having to generate the objects in the edmx etc etc?
 
Thanks


Posted By: ting
Date Posted: 25-Jun-2010 at 2:19pm
Since the Entity Framework only supports schemas at design-time, you would have to do this through POCO iintegration or call InvokeServerMethod and manually grab the data through the ADO Provider.


Posted By: dpollot44
Date Posted: 12-Jul-2010 at 9:44am
What you cannot do is to use EF or DevForce to query against back-end database tables that are neither part of your EF model nor accessed by one of your server-side methods that returns POCOs.

We have a need to execute arbitrary SQL against our legacy database, and this includes calling functions, executing stored procedures, etc.  Entity Framework absolutely DOES allow you to do this so long as you define classes that match properties to columns 1:1 (By virtue of their
ExecuteStoreQuery<T> and ExecuteStoreCommand methods). This allows us to execute queries that return types (basically data sets) that are not part of the Edm model.

What I gleaned from the brief read through that I did on PassThruESQL queries is that they only support returning types that are defined in the Edm model (within the edmx).  Is this true?  Are you guys deriving from ObjectContext in anyway that might allow us to do what we're looking to do as simply as the mechanism provided by EF?


Posted By: ting
Date Posted: 13-Jul-2010 at 8:28pm
Yes, you are correct, and what you are doing in the Entity Framework is also supported by DevForce. (It is a bug if you can accomplish something in the Entity Framework, but not in DevForce.)
 
When you map those functions/stored procs in the Entity Framework, DevForce will generate code that will allow you to call the methods in an n-tier environment.  They can return entities as well as complex types or scalars.
 



Print Page | Close Window