This is a migrated thread and some comments may be shown as answers.

casting IQueryResult to domain object

1 Answer 90 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Bill
Top achievements
Rank 1
Bill asked on 19 Nov 2009, 06:34 PM
Hi,

I am calling a stored procedure that returns an address object. The orm returns it as an IQueryResult object. In my domain, I have an address class with the exact same properties as what the IQueryResult  object has. Is there a way to direct cast the IQueryResult  to the address type in the domain? How can I cast the orm IQueryResult  object to the address class in the domain?

Bill

1 Answer, 1 is accepted

Sort by
0
Accepted
PetarP
Telerik team
answered on 20 Nov 2009, 04:11 PM
Hello Bill,

When returning a result from a stored procedure you have two options:
1. The stored procedure will either return an entire persistent class (in your case an entire address object)
2. A projection based on single or multiple tables will be returned. In that case there is no way to map the result to a specific class so it is transferred to an object array instead.

If you are returning an entire object then you can set the return type of the stored procedure to be a specific persistent class. This can be achieved through the reverse mapping wizard:
1. Run the reverse mapping wizard.
2. Go to the Advanced View tab.
3. Select the stored procedure you wish to generate
4. Select from the Result combo box the persistent class that will be returned.
5. Set the generate method property to true.
6. Click Generate & Save config.
Using this approach you can map the result of a stored procedure to a specific persistent class.

All the best,
Petar
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Development (API, general questions)
Asked by
Bill
Top achievements
Rank 1
Answers by
PetarP
Telerik team
Share this question
or