public List <Entity> GetMasterDetailConditionSort <Detail>(Expression <Func <Entity, bool> > masterPredicate,
                                                                   Expression <Func <Detail, bool> > detailPredicate,
                                                                   SortingOptions <Entity> sortOption)
        {
            using (var db = dbFactory.Open())
            {
                var sqlExp = db.From <Entity>()
                             .Join <Detail>();

                if (masterPredicate != null)
                {
                    sqlExp = sqlExp.Where(masterPredicate);
                }

                if (detailPredicate != null)
                {
                    sqlExp = sqlExp.Where <Detail>(detailPredicate);
                }

                if (sortOption != null)
                {
                    sqlExp = sortOption.BuildSortExp(sqlExp);
                }


                return(db.Select(sqlExp.SelectDistinct()));
            }
        }
        public List <TResult> GetByConditionSort <TResult>(Expression <Func <Entity, bool> > predicate,
                                                           Expression <Func <Entity, object> > selector,
                                                           SortingOptions <Entity> sortOption)
        {
            using (var db = dbFactory.Open())
            {
                var sqlExp = db.From <Entity>();

                if (predicate != null)
                {
                    sqlExp = sqlExp.Where(predicate);
                }

                if (sortOption != null)
                {
                    sqlExp = sortOption.BuildSortExp(sqlExp);
                }
                return(db.Select <TResult>(sqlExp.Select(selector)));
            }
        }
        public Dictionary <TKey, TValue> GetDictByConditionSort <TKey, TValue>(Expression <Func <Entity, bool> > predicate,
                                                                               Expression <Func <Entity, object> > fields,
                                                                               SortingOptions <Entity> sortOption)
        {
            using (var db = dbFactory.Open())
            {
                var sqlExp = db.From <Entity>();

                if (predicate != null)
                {
                    sqlExp = sqlExp.Where(predicate);
                }


                if (sortOption != null)
                {
                    sqlExp = sortOption.BuildSortExp(sqlExp);
                }

                return(db.Dictionary <TKey, TValue>(sqlExp.Select(fields)));
            }
        }