public TemplateCollection FetchByQuery(Query qry)
        {
            TemplateCollection coll = new TemplateCollection();

            coll.LoadAndCloseReader(qry.ExecuteReader());
            return(coll);
        }
        public TemplateCollection FetchAll()
        {
            TemplateCollection coll = new TemplateCollection();
            Query qry = new Query(Template.Schema);

            coll.LoadAndCloseReader(qry.ExecuteReader());
            return(coll);
        }
        public static MettleSystems.dashCommerce.Content.TemplateCollection GetTemplateCollection(int varTemplateRegionId)
        {
            SubSonic.QueryCommand cmd = new SubSonic.QueryCommand(
                "SELECT * FROM dashCommerce_Content_Template INNER JOIN dashCommerce_Content_Template_TemplateRegion_Map ON " +
                "dashCommerce_Content_Template.TemplateId=dashCommerce_Content_Template_TemplateRegion_Map.TemplateId WHERE dashCommerce_Content_Template_TemplateRegion_Map.TemplateRegionId=@TemplateRegionId", TemplateRegion.Schema.Provider.Name);

            cmd.AddParameter("@TemplateRegionId", varTemplateRegionId, DbType.Int32);
            IDataReader        rdr  = SubSonic.DataService.GetReader(cmd);
            TemplateCollection coll = new TemplateCollection();

            coll.LoadAndCloseReader(rdr);
            return(coll);
        }
        public static void SaveTemplateMap(int varTemplateRegionId, TemplateCollection items)
        {
            QueryCommandCollection coll = new SubSonic.QueryCommandCollection();
            //delete out the existing
            QueryCommand cmdDel = new QueryCommand("DELETE FROM dashCommerce_Content_Template_TemplateRegion_Map WHERE TemplateRegionId=@TemplateRegionId", TemplateRegion.Schema.Provider.Name);

            cmdDel.AddParameter("@TemplateRegionId", varTemplateRegionId);
            coll.Add(cmdDel);
            DataService.ExecuteTransaction(coll);
            foreach (Template item in items)
            {
                TemplateTemplateRegionMap varTemplateTemplateRegionMap = new TemplateTemplateRegionMap();
                varTemplateTemplateRegionMap.SetColumnValue("TemplateRegionId", varTemplateRegionId);
                varTemplateTemplateRegionMap.SetColumnValue("TemplateId", item.GetPrimaryKeyValue());
                varTemplateTemplateRegionMap.Save();
            }
        }
        public TemplateCollection FetchByID(object TemplateId)
        {
            TemplateCollection coll = new TemplateCollection().Where("TemplateId", TemplateId).Load();

            return(coll);
        }