/// <summary> /// 根据查询条件,返回一个查询对象。一般用于参数化查询。 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="condition">查询条件</param> /// <returns>返回查询对象xQuery,可以进一步参数化赋值,并得到结果</returns> public static xQuery <T> find <T>(String condition) where T : IEntity { ObjectInfo state = new ObjectInfo(typeof(T)); Query q = ObjectDB.Find(state, condition); return(new xQuery <T>(q)); }
public static String GetSameTypeIds(Type throughType, Type t, int id) { // 1029 ObjectInfo state = new ObjectInfo(throughType); String relationPropertyName = state.EntityInfo.GetRelationPropertyName(t); EntityPropertyInfo info = state.EntityInfo.FindRelationProperty(t); String ids = ObjectDB.Find(state, relationPropertyName + ".Id=" + id).get(info.Name + ".Id"); EntityPropertyInfo property = state.EntityInfo.GetProperty(relationPropertyName); String sql = String.Format("select distinct {0} from {1} where {2} in ({3}) and {0}<>{4}", property.ColumnName, state.EntityInfo.TableName, info.ColumnName, ids, id); IDbCommand command = DataFactory.GetCommand(sql, DbContext.getConnection(state.EntityInfo)); IDataReader rd = null; StringBuilder builder = new StringBuilder(); try { rd = command.ExecuteReader(); while (rd.Read()) { builder.Append(rd[0]); builder.Append(","); } } catch (Exception exception) { logger.Error(exception.Message); throw new OrmException(exception.Message, exception); } finally { OrmHelper.CloseDataReader(rd); } return(builder.ToString().TrimEnd(',')); }
public static IList FindDataOther(Type throughType, Type t, String order, int id) { // 1029 ObjectInfo state = new ObjectInfo(throughType); String relationPropertyName = state.EntityInfo.GetRelationPropertyName(t); EntityPropertyInfo info = state.EntityInfo.FindRelationProperty(t); state.Order = order; state.include(info.Name); return(ObjectDB.Find(state, relationPropertyName + ".Id=" + id).listChildren(info.Name)); }
/// <summary> /// 根据条件查询 /// </summary> /// <param name="t"></param> /// <param name="condition">查询对象</param> /// <returns>返回查询对象Query,可以进一步参数化赋值,并得到结果</returns> public static Query find(Type t, String condition) { ObjectInfo state = new ObjectInfo(t); return(ObjectDB.Find(state, condition)); }