Example #1
0
 public void SaveQuery(string queryId, string sql)
 {
     using (var dc = new CriteriaDataContext())
     {
         var cq = dc.O2CVQueries.FirstOrDefault(x => x.Id == Convert.ToInt64(queryId));
         if (cq == null)
         {
             throw new Exception(
                       $"Could not find query to save - query id {queryId} ");
         }
         cq.QuerySql     = sql;
         cq.ModifiedDate = Now;
         dc.SubmitChanges();
     }
 }
Example #2
0
 public void CreateQuery(O2CV1QueryDto queryDto)
 {
     using (var dc = new CriteriaDataContext())
     {
         var q = new O2CVQuery
         {
             QueryName   = queryDto.QueryName,
             QuerySql    = queryDto.QuerySql,
             CreatedBy   = queryDto.CreatedBy,
             Deleted     = queryDto.Deleted,
             Description = queryDto.Description,
             CreatedDate = Now
         };
         dc.O2CVQueries.InsertOnSubmit(q);
         dc.SubmitChanges();
     }
 }
Example #3
0
        public O2CV1QueryDto SaveQuery(O2CV1QueryDto queryDto)
        {
            using (var dc = new CriteriaDataContext())
            {
                var cq = dc.O2CVQueries.FirstOrDefault(x => x.Id == Convert.ToInt64(queryDto.QueryId));
                if (cq == null)
                {
                    throw new Exception(
                              $"Could not find query to save - query id {queryDto.QueryId} query name {queryDto.QueryName}");
                }
                cq.QueryName    = queryDto.QueryName;
                cq.QuerySql     = queryDto.QuerySql;
                cq.Deleted      = queryDto.Deleted;
                cq.Description  = queryDto.Description;
                cq.ModifiedBy   = queryDto.ModifiedBy;
                cq.ModifiedDate = Now;
                dc.SubmitChanges();

                return(queryDto);
            }
        }