예제 #1
0
        public virtual ContentResult GetRows(string rowsViewName)
        {
            XmlDocument xml = new XmlDocument();

            xml.InnerXml = "<xml></xml>";

            Durados.Web.Mvc.View view = (Durados.Web.Mvc.View)Map.Database.Views[rowsViewName];

            Dictionary <string, object> values = new Dictionary <string, object>();

            Dictionary <string, SortDirection> sortColumns = new Dictionary <string, SortDirection>();

            sortColumns.Add(view.DisplayColumn, SortDirection.Asc);
            int      rowCount = 0;
            DataView dataView = view.FillPage(1, 1000, values, false, sortColumns, out rowCount, null, null);


            foreach (DataRow row in dataView.Table.Rows)
            {
                XmlElement   element = xml.CreateElement("Row");
                XmlAttribute key     = xml.CreateAttribute("key");
                key.Value = view.GetPkValue(row);
                element.Attributes.Append(key);
                XmlAttribute name = xml.CreateAttribute("name");
                name.Value = GetDisplayName(view, row);
                element.Attributes.Append(name);

                AddAdditionals(view, xml, element, row);
                xml.DocumentElement.AppendChild(element);
            }
            return(this.Content(xml.InnerXml, "text/xml"));
        }