更新时间:2023-09-13 12:12:40
***建议不成功,可能是因为我的解决方案中的枚举是在用户定义的类型中更远的上游映射到表中列的属性。
我通过使用以下方法查询实体框架代码外的数据库来解决这个问题:
The *** suggestion was unsuccessful, possibly because the enums in my solution are in user defined types further upstream from the property that maps to the column on the table.
I have worked around it by querying the database outside Entity Framework code using:
MySqlCommand cmd = new MySqlCommand();
cmd.Connection = m_Connection; // Passed in from the controller
cmd.CommandType = CommandType.Text;
cmd.CommandText =
String.Format(@"select Expiry_Type,
Unit_ID,
Fixed_Interval_ID,
Day,
Number_Interval_Units
from ExpiryMaster
where Expiry_ID = {0}
and valid_from <= '{1}'
and(valid_to >= '{1}' or valid_to is NULL)",
arg_Param_ID, m_OrigDate);
MySqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
// Process the result
}