我剛開始使用Azure'移動服務',我使用C#作爲後端。我試圖返回Guid
回到客戶端,但我收到錯誤:「Cannot convert source type int to target type Guid
」。C#後端移動服務:return Guid
這裏是我的代碼:
型號:
public class MobileRegistration : EntityData
{
public Guid MobileRegistrationId { get; set; }
}
控制器:
public async Task<Guid> GetMobileRegistrationId()
{
using (var context = new CustomeeMobileServiceContext())
{
var db = context.Database;
var model = new MobileRegistration();
// The error is here (I need to get Guid from the SP):
//Error: Cannot convert source type int to target type Guid
model.MobileRegistrationId = await db.ExecuteSqlCommandAsync("EXEC dbo.MobileRegistration.GetMobileRegistrationId");
return model.MobileRegistrationId;
}
}
存儲過程:
Create PROCEDURE GetMobileRegistrationId
AS
DECLARE @MobileRegistrationID uniqueidentifier
set @MobileRegistrationID = NEWID()
INSERT
INTO MobileRegistration (MobileRegistrationID)
VALUES (@MobileRegistrationID)
select @MobileRegistrationID as MobileRegistrationID
而且你甚至不打擾告訴我們哪裏......你得到的錯誤。驚人。有一些水晶球?不要傾倒我們很多代碼,然後認爲這是我們的工作來完成你的工作。 – TomTom 2014-12-03 09:01:09
不要生氣......我會添加它。 – Eyal 2014-12-03 09:02:35
寧可隔離錯誤並丟棄不需要的其餘部分。根據常見問題,您必須提供必要的最小代碼來重現問題。 – TomTom 2014-12-03 09:03:31