/// <summary> /// 根据属性查询数据。框架已经给对象的所有属性做了索引。 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="propertyName">属性名称</param> /// <param name="val">属性的值</param> /// <returns>返回数据列表</returns> public static List <CacheObject> findBy(Type t, String propertyName, Object val) { findAll(t); IList list = MemoryDB.FindBy(t, propertyName, val); return(db.getResults <CacheObject>(list)); }
/// <summary> /// 查询类型 T 的所有数据 /// </summary> public static List <CacheObject> findAll(Type t) { IList list = MemoryDB.FindAll(t); return(db.getResults <CacheObject>(list)); }
/// <summary> /// 根据 id 查询某条数据 /// </summary> public static CacheObject findById(Type t, int id) { return(MemoryDB.FindById(t, id)); }
/// <summary> /// 检索出所有对象 /// </summary> /// <returns></returns> public IList findAll() { return(MemoryDB.FindAll(this.GetType())); }
/// <summary> /// 根据属性名,检索出对象 /// </summary> /// <param name="propertyName"></param> /// <param name="val"></param> /// <returns></returns> public IList findBy(String propertyName, Object val) { findAll(); return(MemoryDB.FindBy(this.GetType(), propertyName, val)); }
/// <summary> /// 删除数据 /// </summary> public void delete() { MemoryDB.Delete(this); }
/// <summary> /// 根据 id 检索对象 /// </summary> /// <param name="id"></param> /// <returns></returns> public CacheObject findById(long id) { return(MemoryDB.FindById(this.GetType(), id)); }
/// <summary> /// 更新数据:只针对特性数据做索引 /// </summary> /// <param name="dic"></param> public void updateByIndex(Dictionary <String, Object> dic) { MemoryDB.updateByIndex(this, dic); }
/// <summary> /// 更新数据 /// </summary> /// <returns></returns> public Result update() { return(MemoryDB.Update(this)); }
/// <summary> /// 插入数据:针对若干属性做索引 /// </summary> /// <param name="dic"></param> public void insertByIndex(Dictionary <String, Object> dic) { MemoryDB.InsertByIndex(this, dic); }
/// <summary> /// 插入数据:只针对特定属性做索引,提高速度 /// </summary> /// <param name="propertyName"></param> /// <param name="pValue"></param> public void insertByIndex(String propertyName, Object pValue) { MemoryDB.InsertByIndex(this, propertyName, pValue); }
/// <summary> /// 插入数据:并对所有属性做索引,速度较慢 /// </summary> public void insert() { MemoryDB.Insert(this); }