Beispiel #1
0
        public static CallbackDataset GetMappedObjects <T>(int?topCount, string sqlFilterExpression, string sqlOrderExpression) where T : class
        {
            AdsConnection connection = CreateConnection();

            CallbackDataset cbd = new CallbackDataset();

            AdsDataContext context = new AdsDataContext(connection);

            try
            {
                cbd.ds = new DataSet();

                context.Fill <T>(cbd.ds, topCount, sqlFilterExpression, sqlOrderExpression);

                cbd.success = true;
            }
            catch (Exception e)
            {
                cbd.success = false;
                cbd.info    = e.Message + ", SQL: " + context.LastSqlCommandText;
            }
            finally
            {
                connection.Close();
            }

            return(cbd);
        }
Beispiel #2
0
        public static CallbackObject GetMappedObject <T>(object obj)
            where T : class
        {
            AdsConnection connection = CreateConnection();

            connection.Open();

            var cbo = new CallbackObject();

            var context = new AdsDataContext(connection);

            try
            {
                cbo.obj = context.Get <T>(obj);

                cbo.success = true;
            }
            catch (Exception e)
            {
                cbo.success = false;
                cbo.info    = e.Message + ", SQL: " + context.LastSqlCommandText;
            }
            finally
            {
                connection.Close();
            }

            return(cbo);
        }
Beispiel #3
0
        public static Callback SaveMappedObject(object obj)
        {
            AdsConnection connection = CreateConnection();

            connection.Open();

            Callback cb = new Callback();

            cb.success = false;

            AdsDataContext context = new AdsDataContext(connection);

            try
            {
                context.SaveOrUpdate(obj);

                cb.tknkey  = (uint)context.GetAutoIncPrimaryKeyValue(obj);
                cb.success = true;
            }
            catch (Exception e)
            {
                cb.success = false;
                cb.info    = e.Message + ", SQL: " + context.LastSqlCommandText;
            }
            finally
            {
                connection.Close();
            }

            return(cb);
        }
Beispiel #4
0
        public static Callback DeleteMappedObjects <T>(string sqlFilterExpression) where T : class
        {
            AdsConnection connection = CreateConnection();

            connection.Open();

            Callback cb = new Callback();

            cb.success = false;

            AdsDataContext context = new AdsDataContext(connection);

            try
            {
                context.Delete <T>(sqlFilterExpression);

                cb.success = true;
            }
            catch (Exception e)
            {
                cb.success = false;
                cb.info    = e.Message + ", SQL: " + context.LastSqlCommandText;
            }
            finally
            {
                connection.Close();
            }

            return(cb);
        }