我有一個基於EF4模型的測試wcf webservice(REST)併發布在IIS7.5上。一個基本的查詢是wcf返回無效數據
public CfgUser GetUser(string fspId, string userName)
{
return _context.Users.FirstOrDefault(a => a.FspID == fspId && a.UserName == userName && a.WadtDeleted == false);
}
然後我做以下網址測試呼叫在IE9:
https://10.201.2.70/webservices/service.svc/rest/GetUser(EDS,kern)
XML數據返回正確。 SQL事件探查器顯示
exec sp_executesql N'SELECT TOP (2)
[Extent1].[UserId] AS [UserId],
[Extent1].[FSP] AS [FSP],
[Extent1].[UserGroupId] AS [UserGroupId],
[Extent1].[ContactID] AS [ContactID],
[Extent1].[UserName] AS [UserName],
[Extent1].[UserPassword] AS [UserPassword],
[Extent1].[FirstName] AS [FirstName],
[Extent1].[MidName] AS [MidName],
[Extent1].[LastName] AS [LastName],
[Extent1].[CommonName] AS [CommonName],
[Extent1].[enumUserType] AS [enumUserType],
[Extent1].[enumActive] AS [enumActive],
[Extent1].[CreatedBy] AS [CreatedBy],
[Extent1].[wadtDeleted] AS [wadtDeleted],
[Extent1].[wadtModifiedBy] AS [wadtModifiedBy],
[Extent1].[wadtModifiedOn] AS [wadtModifiedOn],
[Extent1].[wadtModifiedOnDTOffset] AS [wadtModifiedOnDTOffset],
[Extent1].[wadtRowID] AS [wadtRowID],
[Extent1].[CreatedOn] AS [CreatedOn],
[Extent1].[CreatedOnDTOffset] AS [CreatedOnDTOffset],
[Extent1].[Email] AS [Email],
[Extent1].[isDeviceUser] AS [isDeviceUser],
[Extent1].[rowguid] AS [rowguid],
[Extent1].[PasswordHash] AS [PasswordHash],
[Extent1].[PasswordModifiedOn] AS [PasswordModifiedOn]
FROM [dbo].[cfgUsers] AS [Extent1]
WHERE (''EDS'' = [Extent1].[FSP]) AND ([Extent1].[UserName] = @p__linq__0) AND (0 =
[Extent1].[wadtDeleted])',N'@p__linq__0 varchar(8000)',@p__linq__0='kern'
如果我再做另一個直接調用與網址:
https://10.201.2.70/webservices/service.svc/rest/GetUser(recserv,recserv-admin)
我收到一個請求錯誤。看來,EF linq查詢保留了傳遞給原始fspId參數(即「EDS」)的值。 SQL事件探查器顯示
exec sp_executesql N'SELECT TOP (2)
[Extent1].[UserId] AS [UserId],
[Extent1].[FSP] AS [FSP],
[Extent1].[UserGroupId] AS [UserGroupId],
[Extent1].[ContactID] AS [ContactID],
[Extent1].[UserName] AS [UserName],
[Extent1].[UserPassword] AS [UserPassword],
[Extent1].[FirstName] AS [FirstName],
[Extent1].[MidName] AS [MidName],
[Extent1].[LastName] AS [LastName],
[Extent1].[CommonName] AS [CommonName],
[Extent1].[enumUserType] AS [enumUserType],
[Extent1].[enumActive] AS [enumActive],
[Extent1].[CreatedBy] AS [CreatedBy],
[Extent1].[wadtDeleted] AS [wadtDeleted],
[Extent1].[wadtModifiedBy] AS [wadtModifiedBy],
[Extent1].[wadtModifiedOn] AS [wadtModifiedOn],
[Extent1].[wadtModifiedOnDTOffset] AS [wadtModifiedOnDTOffset],
[Extent1].[wadtRowID] AS [wadtRowID],
[Extent1].[CreatedOn] AS [CreatedOn],
[Extent1].[CreatedOnDTOffset] AS [CreatedOnDTOffset],
[Extent1].[Email] AS [Email],
[Extent1].[isDeviceUser] AS [isDeviceUser],
[Extent1].[rowguid] AS [rowguid],
[Extent1].[PasswordHash] AS [PasswordHash],
[Extent1].[PasswordModifiedOn] AS [PasswordModifiedOn]
FROM [dbo].[cfgUsers] AS [Extent1]
WHERE (''EDS'' = [Extent1].[FSP]) AND ([Extent1].[UserName] = @p__linq__0) AND (0 =
[Extent1].[wadtDeleted])',N'@p__linq__0 varchar(8000)',@p__linq__0='recserv-admin'
如果我重新啓動IIS服務,則第二個請求將工作,所以有明顯的領帶與IIS的地方? FSP和用戶之間有一對多關聯。
任何幫助/指針aprpeciated
你可以發表你的界面如何看起來像? – Rajesh