Example #1
0
        /// <summary>
        /// 返回一个Query节
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public QuerySection <T> From <T>(TableRelation <T> relation)
            where T : Entity
        {
            //重新实例化一个Query
            var query = new QuerySection <T>(relation.GetFromSection(), dbProvider, this);

            //处理前n条
            if (relation.GetTopSize() > 0)
            {
                query = query.GetTop(relation.GetTopSize());
            }

            return(query);
        }
Example #2
0
 /// <summary>
 /// 选择前n条
 /// </summary>
 /// <param name="topSize"></param>
 /// <returns></returns>
 public TopSection <T> GetTop(int topSize)
 {
     return(query.GetTop(topSize));
 }
Example #3
0
 /// <summary>
 /// 返回ISourceReader
 /// </summary>
 /// <returns></returns>
 public SourceReader ToReader(int topSize)
 {
     return(query.GetTop(topSize).ToReader());
 }
Example #4
0
 /// <summary>
 /// 返回T
 /// </summary>
 /// <returns></returns>
 public T ToSingle <T>()
     where T : class
 {
     return(query.GetTop(1).ToReader().ConvertTo <T>()[0]);
 }