New Posts New Posts RSS Feed: Silverlight Stored Procedures
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Silverlight Stored Procedures

 Post Reply Post Reply
Author
rickadams View Drop Down
Newbie
Newbie
Avatar

Joined: 04-Mar-2011
Posts: 12
Post Options Post Options   Quote rickadams Quote  Post ReplyReply Direct Link To This Post Topic: Silverlight Stored Procedures
    Posted: 12-Dec-2011 at 2:25pm
I am having implementing a stored procedure and returning a complex type. Here is the stored proc
 
ALTER PROCEDURE [dbo].[PromoCatalogItem_TotalQuantity]
 
@promoCatalog_ID decimal(18,0),
@member_ID decimal(18,0)
AS
BEGIN
    SET NOCOUNT ON;
    SELECT PromoCatalog_Item_ID,
           SUM(T2.Promo.value('(DATACOUNT)[1]', 'decimal(18,6)')) AS TotalOnQuantity ,
           COUNT(*) as Times
    FROM Member_Promocatalog_Data
    CROSS APPLY ReportData1.nodes('/DATA/ONPROMO') T2(Promo)
    WHERE Member_PromoCatalog_ID = @promoCatalog_ID
    AND ReceiverID = @member_ID
    GROUP BY PromoCatalog_Item_ID
END
 
I wish to return a complex type which is the rows from the SELECT statement. I have created a FunctionImport defined for this stored proc but I am unable to return the results. I have verified that the correct paramters are passed to the SP and I have validated that the SP returns a result with this parameters using SQL Enterprise Manager. Here is the code I am using in Silverlight
 
        public INotifyCompleted load_PromoCatalogItemOrderLevels_Coroutine( Decimal promoCatalogID, Decimal memberID)
        {
            var q = mgrPromoCatalog.PromoCatalogItem_TotalQuantityQuery(memberID, promoCatalogID);
            return mgrPromoCatalog.ExecuteQueryAsync(q);
        } 
and I call this in a Coroutine using StartParallel. Here is the Completed handler ( I Have deleted other code to minimize the amount of text )
 
       public void load_MemberPromoCatalogEntities(Member_PromoCatalog memberPromoCatalog, Decimal memberID)
        {
            var coop = Coroutine.StartParallel(() => load_MemberPromoCatalogEntitiesCoroutine(memberPromoCatalog, memberID));
            coop.Completed += (sender, args) =>
            {
                if (args.CompletedSuccessfully)
                {
                    //get the results from our stored procedure call
                    var results = args.Notifications[5] 
                 }
                else
                {
                }
            };
        }
 
I see no errors in the results but I have not data returning. Any help would be appreciated
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 14-Dec-2011 at 12:31pm
Hi rickadams;

Sorry for the delayed reply. Here's a sample in Silverlight showing a similar example using NorthwindIB on how to use StoredProcQuery returning a complex type with parallel coroutines.

Back to Top
rickadams View Drop Down
Newbie
Newbie
Avatar

Joined: 04-Mar-2011
Posts: 12
Post Options Post Options   Quote rickadams Quote  Post ReplyReply Direct Link To This Post Posted: 15-Dec-2011 at 8:55am
thanks Denis. the example code did the trick and I am now able to get my complex types returned correctly

Rick
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down