public ActionResult ConvertToQuery(ContactSearchModel m) { var cc = DbUtil.Db.ScratchPadCondition(); cc.Reset(DbUtil.Db); var comp = CompareType.Equal; var clause = cc.AddNewClause(QueryType.MadeContactTypeAsOf, comp, "1,T"); clause.Program = m.Ministry ?? 0; clause.StartDate = m.StartDate ?? DateTime.Parse("1/1/2000"); clause.EndDate = m.EndDate ?? DateTime.Today; var cvc = new CodeValueModel(); var q = from v in cvc.ContactTypeList() where v.Id == m.ContactType select v.IdCode; var idvalue = q.Single(); clause.CodeIdValue = idvalue; cc.Save(DbUtil.Db); if (ViewExtensions2.UseNewLook()) return Redirect("/Query/" + cc.Id); return Redirect("/QueryBuilder2/Main/{0}".Fmt(cc.Id)); }