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); }
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); }
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); }
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); }