次の表の形式でデータを返すストアド プロシージャがあります。
ID int null,
RestaurentName varchar(250),
Address nvarchar(150),
Area nvarchar(150),
City nvarchar(50),
Postcode nvarchar(50),
DeliveryPrice decimal(4,2),
DeliveryTime nvarchar(50),
Latitude nvarchar(50),
Longitude nvarchar(50),
LogoLocation nvarchar(50),
Rating float,// returns AVG of rating
Discount money
EF で関数のインポートを行いました。サイトを実行すると、次のエラーが表示されます
「SearchRestaurantByKey_Result」の「Rating」プロパティを「Double」値に設定できませんでした。このプロパティは、'Decimal' 型の null 以外の値に設定する必要があります。
誰もこれを解決する方法を知っていますか??
編集: これは私がエラーを抱えている場所です:
var query = (from p in dc.GetRestaurantByAreaAndCategory(area,type)
select new RestaurantViewModel()
{
Name = p.RestaurentName,
Address = p.Address,
City = p.City,
Postcode = p.Postcode,
ID = Convert.ToInt32(p.ID),
LogoPath = p.LogoLocation,
DeliveryPrice = Convert.ToDecimal(p.DeliveryPrice),
DeliveryTime = p.DeliveryTime,
discount = p.Discount,
Rating=Convert.ToDouble(p.Rating) //here is the error.
}).ToList();
RestaurantViewModel() では、評価プロパティは Double です。