虽然返回值不为空,但我在
var currentTakipciler = TwitterCacheDepo.GetTakipciler(TemaUserID)
我在调试中查看了返回值,它不是空的,但我得到了空引用异常。
try
{
var currentTakipciler = TwitterCacheDepo.GetTakipciler(TemaUserID);
}
catch (Exception ex)
{
Utils.LogYaz(ex.ToString());
}
public class TwitterCacheDepo
{
...
...
public static Dictionary<int, string> GetTakipciler(string TemaUserID)
{
try
{
Dictionary<int, string> returnValue = new Dictionary<int, string>();
if (allTakipciler != null && allTakipciler.Rows.Count > 0)
{
returnValue = allTakipciler.AsEnumerable().Where(x => x.Field<DateTime?>("BitTarih").Equals(null) && x.Field<string>("TemaUserID").Equals(TemaUserID)).ToDictionary(x => x.Field<int>("ID"), y => y.Field<string>("UserID"));// SqlDataBase.SqlGetTable("SELECT ID,TemaUserID,UserID,BitTarih FROM TBL_TwitterUserTakipciler WHERE BitTarih IS NULL SID = " + 4663);
return returnValue;
}
else
{
allTakipciler = SqlDataBase.SqlGetTable("SELECT ID,TemaUserID,UserID,BitTarih FROM TBL_TwitterUserTakipciler WHERE SID = " + 4663);
return allTakipciler.AsEnumerable().Where(x => x.Field<DateTime?>("BitTarih").Equals(null) && x.Field<string>("TemaUserID").Equals(TemaUserID)).ToDictionary(x => x.Field<int>("ID"), y => y.Field<string>("UserID"));
}
}
catch (Exception ex)
{
Utils.LogYaz(ex.Message.ToString());
return null;
}
}
}