第一个问题:
/// <summary>
/// 获得一个实体
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="keyValue">主键值</param>
/// <returns>查询到的对象</returns>
public virtual T GetEntityByKey<T>(object keyValue) where T : class
{
return EM.GetObjectByKey(new EntityKey(EntityContainerName + "." + EntitySetNameMap[typeof(T).Name], GetKeyName(typeof(T)), keyValue)) as T;
}报错:键字段“GRIDID”的类型应为“System.Decimal”,但提供的值实际是“System.Int32”类型。
参数名: key第二个问题
userInfo.Tell =ub.TELL;
其中ub.TELL为数据库中的CHAR(20)类型数据,为手机号码,而userInfo.Tell为int数据,该怎么转换呢,
如果写为userInfo.Tell =int.Parse(ub.TELL),则报错“值对于 Int32 太大或太小。”
/// <summary>
/// 获得一个实体
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="keyValue">主键值</param>
/// <returns>查询到的对象</returns>
public virtual T GetEntityByKey<T>(object keyValue) where T : class
{
return EM.GetObjectByKey(new EntityKey(EntityContainerName + "." + EntitySetNameMap[typeof(T).Name], GetKeyName(typeof(T)), keyValue)) as T;
}报错:键字段“GRIDID”的类型应为“System.Decimal”,但提供的值实际是“System.Int32”类型。
参数名: key第二个问题
userInfo.Tell =ub.TELL;
其中ub.TELL为数据库中的CHAR(20)类型数据,为手机号码,而userInfo.Tell为int数据,该怎么转换呢,
如果写为userInfo.Tell =int.Parse(ub.TELL),则报错“值对于 Int32 太大或太小。”
userInfo.Tell =long.Parse(ub.TELL)
可以用Int64,long这些转换
if(key!=null)
{
key=(Decimal)key;
GetEntityByKey(key)
}2
userInfo.Tell =Int64.Parse(ub.TELL)
if(key!=null)
{
key=(Decimal)key;
GetEntityByKey(key)
}
2 userInfo.Tell改成string类型,然后
userInfo.Tell =ub.TELL.toSting();