public object SelectById(Type type, Object id) { QueryInfo info = new QueryInfo(type); info.CustomSQL = MappingInfo.GetMappingInfo(type).SelectById; info.AddParam(GetPrimaryKey(type), id); return(Dao.Query(info.ToSQLString(), info.Parameters, type) .SingleOrDefault()); }
public T SelectById <T>(Object id) { string sql = MappingInfo.GetMappingInfo <T>().SelectById; return(Dao.Query <T>(sql, new Dictionary <string, object>() { { GetPrimaryKey(typeof(T)), id } } ).SingleOrDefault()); }
///获取xml中配置的 User.Select语句, 或者根据对象的属性映射生成语句 private string GetMappedOrDefaultSql(Type type) { if (type == null) { throw new ArgumentNullException("MappingType", "QueryInfo未指定查询的对象类型!"); } string key = type.Name + ".Select"; string sql = StatementParser.GetMappedStaticSql(key); if (sql.Equals(key)) { sql = (MappingInfo.GetMappingInfo(type).Select + "t"); } return(sql); }
public bool Delete <T>(Object id) { if (id == null) { return(false); } Type type = typeof(T); MappingInfo info = MappingInfo.GetMappingInfo <T>(); return(Dao.Execute( info.Delete, new Dictionary <string, object>() { { GetPrimaryKey(type), id } } ) == 1); }