Ejemplo n.º 1
0
        /// <summary>
        /// 获取选项列表
        /// </summary>
        /// <returns></returns>
        public IEnumerable <ListItem> GetItems()
        {
            var databaseManager = Application.Ioc.Resolve <DatabaseManager>();

            using (var context = databaseManager.CreateContext()) {
                foreach (var data in context.Query <TData>())
                {
                    yield return(new ListItem(data.ToString(), EntityTrait.GetPrimaryKey(data).ToString()));
                }
            }
        }
        /// <summary>
        /// 获取选项列表
        /// </summary>
        /// <returns></returns>
        public IEnumerable <ListItem> GetItems()
        {
            var databaseManager = Application.Ioc.Resolve <DatabaseManager>();
            var propertyName    = RecyclableTrait.For <TData>().PropertyName;
            var expression      = ExpressionUtils.MakeMemberEqualiventExpression <TData>(propertyName, false);

            using (var context = databaseManager.CreateContext()) {
                foreach (var data in context.Query <TData>().Where(expression))
                {
                    yield return(new ListItem(data.ToString(), EntityTrait.GetPrimaryKey(data).ToString()));
                }
            }
        }