Exemple #1
0
        //[RepositoryQuery]
        //public virtual BookList GetBy(BookQueryCriteria criteria)
        //{
        //    //自定义查询示例。
        //    return (BookList)this.QueryList(q =>
        //    {
        //        q.Constrain(Book.BookCategoryIdProperty).Equal(criteria.BookCategoryId)
        //            .And().Constrain(Book.NameProperty).Contains(criteria.BookName);
        //    });
        //}

        public BookList GetBy(BookQueryCriteria criteria)
        {
            return((BookList)this.GetBy(new CommonQueryCriteria
            {
                new PropertyMatch(Book.BookCategoryIdProperty, criteria.BookCategoryId),
                new PropertyMatch(Book.NameProperty, criteria.BookName),
            }));

            //            //使用 SQL 的自定义查询示例。
            //            this.QueryDb(new SqlQueryDbArgs
            //            {
            //                FormatSql = @"
            //                Select * from Book
            //                where BookCategoryId = {0} and Name = '{1}'",
            //                Parameters = new object[] { criteria.BookCategoryId, criteria.BookName }
            //            });
        }
Exemple #2
0
        /// <summary>
        /// 查询面板
        /// </summary>
        /// <param name="criteria"></param>
        protected EntityList FetchBy(BookQueryCriteria criteria)
        {
            //自定义查询示例。
            return(this.QueryList(q =>
            {
                q.Constrain(Book.BookCategoryIdProperty).Equal(criteria.BookCategoryId)
                .And().Constrain(Book.NameProperty).Contains(criteria.BookName);
            }));

            //            //使用 SQL 的自定义查询示例。
            //            this.QueryDb(new SqlQueryDbArgs
            //            {
            //                FormatSql = @"
            //                Select * from Book
            //                where BookCategoryId = {0} and Name = '{1}'",
            //                Parameters = new object[] { criteria.BookCategoryId, criteria.BookName }
            //            });
        }