Beispiel #1
0
        public static List <TSelectModel> Select2Model <TSelectModel>(IProvider provider, string sql) where TSelectModel : class, new()
        {
            List <TSelectModel> ResultList = new List <TSelectModel>();

            LinqConextClass context = new LinqConextClass(provider);

            try
            {
                context.Open();
                DataContext dataContext = context.Context;
                IEnumerable collections = dataContext.ExecuteQuery((new TSelectModel()).GetType(), sql);
                foreach (var item in collections)
                {
                    TSelectModel temp = item as TSelectModel;
                    ResultList.Add(temp);
                }
            }
            catch (Exception exp)
            {
                throw exp;
            }
            finally
            {
                context.Close();
            }
            return(ResultList);
        }
Beispiel #2
0
        protected List <T> ConextRun(string sql)
        {
            List <T> ResultList = new List <T>();

            LinqConextClass context = new LinqConextClass(this.Provider);

            try
            {
                context.Open();
                DataContext dataContext = context.Context;
                IEnumerable collections = dataContext.ExecuteQuery((new T()).GetType(), sql);
                foreach (var item in collections)
                {
                    T temp = item as T;
                    ResultList.Add(temp);
                }
            }
            catch (Exception exp)
            {
                throw exp;
            }
            finally
            {
                context.Close();
            }
            return(ResultList);
        }
Beispiel #3
0
        protected int ContextExec(string sql)
        {
            LinqConextClass context = new LinqConextClass(this.Provider);

            try
            {
                context.Open();
                DataContext dataContext = context.Context;
                int         x           = dataContext.ExecuteCommand(sql);

                return(x);
            }
            catch (Exception exp)
            {
                return(-1);

                throw exp;
            }
            finally
            {
                context.Close();
            }
            return(-1);
        }