1 回答

TA貢獻(xiàn)1765條經(jīng)驗(yàn) 獲得超5個(gè)贊
為了解決我的性能問題,我從上面的 GET 類中刪除了重載。
我的性能問題來自原始問題,通過更改我的兩個(gè) get 方法(一個(gè)使用 int 和一個(gè) long)的方法名稱來解決。不知道為什么這些重載會(huì)導(dǎo)致問題,但通過刪除重載并直接指定名稱,我的性能問題得到了解決。
我的工人階級(jí)看起來像:
public class API
{
DataAccessClass _dataAccess = new DataAccessClass();
public List<Items> GetById(int id)
{
return _dataAccess.Get(id);
}
protected internal class DataAccessClass
{
protected internal List<Items> GetByInt(int id)
{
using (var context = dbcontext)
{
return context.GetItems();
}
}
protected internal List<Items> GetByLong(long id)
{
using (var context = dbcontext)
{
return context.GetItems();
}
}
}
}
- 1 回答
- 0 關(guān)注
- 189 瀏覽
添加回答
舉報(bào)