嗨,我正在使用实体框架数据库第一个模型。我正在使用自己的存储过程来访问数据,并且我似乎从实体框架中得到了一些类型的结果。
这是我的存储过程:
ALTER PROCEDURE [eConnect].[GetUserPersonalDetails]
@personId int
AS
BEGIN
SELECT Persons.FirstName as FirstName,
Persons.MiddleName as MiddleName,
Persons.LastName as LastName,
Persons.DateOfBirth as DateOfBirth,
Persons.CityOfBirth as CityOfBirth,
Persons.BSN as BSN,
Persons.SecondaryEmail as SecondaryEmail,
Persons.HomePhone as HomePhone,
Persons.WorkPhone as WorkPhone,
Persons.MobilePhone as MobilePhone,
MaterialAddress.StreetName as MaterialAddressStreetName,
MaterialAddress.PostCode as MaterialAddressPostCode,
MaterialAddress.City as MaterialAddressCity,
MaterialAddressCountry.Name as MaterialAddressCountry,
HomeAddress.StreetName as HomeAddressStreetName,
HomeAddress.PostCode as HomeAddressPostCode,
HomeAddress.City as HomeAddressCity,
HomeAddressCountry.Name as HomeAddressCountry,
PostalAddress.StreetName as PostalAddressStreetName,
PostalAddress.PostCode as PostalAddressPostCode,
PostalAddress.City as PostalAddressCity,
PostalAddressCountry.Name as PostalAddressCountry,
Company.Name as CompanyName,
Company.Phone as CompanyPhone,
Avatar.FileName as FileName,
Avatar.RealName as RealName
FROM Sync_Persons as Persons
LEFT JOIN Sync_Addresses as MaterialAddress ON Persons.MaterialAddressID = MaterialAddress.AddressID
AND MaterialAddress.Deletion_Date IS NULL
LEFT JOIN Countries as MaterialAddressCountry ON MaterialAddress.CountryID = MaterialAddressCountry.CountryID
AND MaterialAddressCountry.Deletion_Date IS NULL
LEFT JOIN Sync_Addresses as HomeAddress ON Persons.HomeAddressID = HomeAddress.AddressID
AND HomeAddress.Deletion_Date IS NULL
LEFT JOIN Countries as HomeAddressCountry ON HomeAddress.CountryID = HomeAddressCountry.CountryID
AND HomeAddressCountry.Deletion_Date IS NULL
LEFT JOIN Sync_Addresses as PostalAddress ON Persons.PostalAddressId = PostalAddress.AddressID
AND PostalAddress.Deletion_Date IS NULL
LEFT JOIN Countries as PostalAddressCountry ON PostalAddress.CountryID = PostalAddressCountry.CountryID
AND PostalAddressCountry.Deletion_Date IS NULL
LEFT JOIN Sync_Companies as Company ON Persons.CompanyID = Company.CompanyID
AND Company.Deletion_Date IS NULL
LEFT JOIN Documents as Avatar ON Persons.AvatarPictureDocumentID = Avatar.DocumentID
AND Avatar.Deletion_Date IS NULL
WHERE Persons.PersonID = @personId
添加更新模型并在代码中调用此过程后,如下所示:
m_DataContext.GetUserPersonalDetails(personId);
我回来了:
ObjectResult<GetUserPersonalDetails_Result>
在我的情况下,这个存储过程将始终返回一个值,因为 personId 将是我的表标识符。
我希望得到一个 GetUserPersonalDetails_Result 类型的对象。
如何告诉 Entity Framework 返回 GetUserPersonalDetails_Result 或如何将 ObjectResult 转换为 GetUserPersonalDetails_Result?