New Posts New Posts RSS Feed: Mapping stored procedure to entity
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Mapping stored procedure to entity

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

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Topic: Mapping stored procedure to entity
    Posted: 28-Oct-2011 at 1:03pm
Paolo,

I can't update/delete a projection because it is not mapped to anything in the datasource. i.e. you can't delete 'half' Employee.
If you want to perform these operations, than you should be retrieving the whole entity.

eg consider the table Employees with the following columns:
ID              int 
Name        varchar
HireDate   datetime

and the Employee entity mapped to the table above:
ID              int 
Name        string
HireDate   datetime

if you have a SP that returns all columns, you can map the result to an entity:

SELECT * FROM Employees

However, if you are only retrieving some columns you can't map it to an entity because the result does not compose an entity:

SELECT Name, HireDate FROM Employees

Regards,
   Silvio
Back to Top
pponzano View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Apr-2011
Location: Italy
Posts: 165
Post Options Post Options   Quote pponzano Quote  Post ReplyReply Direct Link To This Post Posted: 27-Oct-2011 at 11:17pm
recieved!
but can I set to a complex type funcion of update/delete read? I don't think so, but I ask...
 
why should I use complex type instead of POCO for my DAL?
 
 
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 27-Oct-2011 at 11:02am
Hi Paolo,

DevForce does support mapping Stored Procedures to Entities. 

In order to do that you have to return all columns of a given table (i.e. all mapped properties of an entity).

In the DevForce Resource Center you will find a sample/walkthrough demonstrating it.

Regards,
   Silvio.
Back to Top
pponzano View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Apr-2011
Location: Italy
Posts: 165
Post Options Post Options   Quote pponzano Quote  Post ReplyReply Direct Link To This Post Posted: 27-Oct-2011 at 6:03am
Dear all,

We have a stored procedure that returns three columns (ID Int32, DESCRIPTION String, COUNTRY String).
We have tried to bind it to an entity (manually defined) and we have also created a Function Import via the wizard.

It results in a EntityServerException thrown at:

void res_Completed(object sender, EntityQueriedEventArgs e)

     {

         e.Results.Cast<MyEntityType>().ForEach(MyList.Add);

     }


The exception message is:
Schema specified is not valid. Errors:
Model1.msl(14,6) : error 2062: No mapping specified for instances of the EntitySet and AssociationSet in the EntityContainer TEST_IDEAEntities.

Using complex types it works. Does DevForce support mappint SP to Enities?
Regards,
Paolo
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down