我们有一个Oracle Package,它返回一个从case语句构建的列。 该列返回0或1,因为Oracle不支持布尔值。
类似的东西:
CASE WHEN EXISTS
SELECT somecolumn from table
WHERE somecondition Then 1
ELSE 0
END AS IcAssignedToGrant
当我们尝试填充代码第一个Object时,映射列是bool,我们从.Net收到一条消息,说它不能将类型十进制转换为类型bool。
所以我尝试这样的事情(在Web API BTW中):
public class NonCompetingRenewalResponse
{
private object _icAssignedToGrant;
public decimal? ApplId { get; set; }
public decimal ContactPIProfileId { get; set; }
public string PiNameList { get; set; }
public string ProgramClassCode { get; set; }
public DateTime? BudgetStartDate { get; set; }
public string AprStatus { get; set; }
public string FullGrantNum { get; set; }
public string ProjectTitle { get; set; }
public string PmChecklistStatusCode { get; set; }
public string GmChecklistStatusCode { get; set; }
public object IcAssignedToGrant
{
get
{
return _icAssignedToGrant;
}
set
{
if ((int)value == 1)
{
_icAssignedToGrant = true;
}
else
{
_icAssignedToGrant = false;
}
}
}
}
}
但是set accessor永远不会被解雇。
有谁知道如何做到这一点?
或者是否有某种方式将传入的小数作为bool从WEB API动作过滤器以某种方式转换为属性?
我也试过了,但是OnPropertyChanged也没有开火:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Web;
namespace Nete.Ireport.Models.ViewModels
{
public class NonCompetingRenewalResponse : INotifyPropertyChanged
{
// Declare the event
public event PropertyChangedEventHandler PropertyChanged;
// Create the OnPropertyChanged method to raise the event
protected void OnPropertyChanged(string name)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(name));
}
}
private object _icAssignedToGrant;
public decimal? ApplId { get; set; }
public decimal ContactPIProfileId { get; set; }
public string PiNameList { get; set; }
public string ProgramClassCode { get; set; }
public DateTime? BudgetStartDate { get; set; }
public string AprStatus { get; set; }
public string FullGrantNum { get; set; }
public string ProjectTitle { get; set; }
public string PmChecklistStatusCode { get; set; }
public string GmChecklistStatusCode { get; set; }
public object IcAssignedToGrant
{
get
{
return _icAssignedToGrant;
}
set
{
if ((int)value == 1)
{
_icAssignedToGrant = true;
OnPropertyChanged("IcAssignedToGrant");
}
else
{
_icAssignedToGrant = false;
OnPropertyChanged("IcAssignedToGrant");
}
}
}
}
}