我有以下使用实体框架的通用Get方法:
/**
* Adds the possibility to auto scroll through sections on touch devices.
*/
function addTouchHandler(){
if(isTouchDevice || isTouch){
//Microsoft pointers
var MSPointer = getMSPointer();
$(document).off('touchstart ' + MSPointer.down).on('touchstart ' + MSPointer.down, touchStartHandler);
$(document).off('touchmove ' + MSPointer.move).on('touchmove ' + MSPointer.move, touchMoveHandler);
}
}
/**
* Removes the auto scrolling for touch devices.
*/
function removeTouchHandler(){
if(isTouchDevice || isTouch){
//Microsoft pointers
var MSPointer = getMSPointer();
$(document).off('touchstart ' + MSPointer.down);
$(document).off('touchmove ' + MSPointer.move);
}
}
是否有可能使用ID列表实现相同的通用功能? 像那样:
public TEntity Get(string id)
{
using (var db = CreateContext())
{
return db.Set<TEntity>().Find(id);
}
}