/// <summary> /// 从指定数据库中抓取相关容器 /// </summary> /// <param name="conn">指定的数据库</param> /// <returns>迭代返回抓取结果</returns> protected virtual IEnumerable <Model.Container> FetchContainersHelper(Predicate <Model.Container> predicate) { SQLiteCommand cmd = new SQLiteCommand(DataBase); cmd.CommandText = $@"Select * From {APM.ContainersTable} Where {APM.ContainerFilter} == {FilterUID}"; using (SQLiteDataReader results = cmd.ExecuteReader()) { while (results.Read()) { Model.Container source = ContainerHelper.FetchFrom(results); if (predicate(source)) { yield return(source); } } } }
/// <summary> /// 依据条件抓取Container /// </summary> /// <param name="predicate">谓词回调</param> /// <returns>抓取结果的迭代器</returns> protected virtual IEnumerable <Model.Container> FetchContainersSource(Predicate <Model.Container> predicate) { SQLiteCommand cmd = new SQLiteCommand(_database); foreach (Model.Filter filter in FetchFiltersSource((f) => true)) { cmd.CommandText = $@"Select * From {APM.ContainersTable} Where {APM.ContainerFilter} == {filter.FilterUID}"; using (SQLiteDataReader results = cmd.ExecuteReader()) { while (results.Read()) { Model.Container container = ContainerHelper.FetchFrom(results); if (predicate(container)) { yield return(container); } } } } }