Beispiel #1
0
        /// <summary>
        /// Converts a single result row
        /// </summary>
        /// <param name="o"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public Row ConvertResult(object o, Context model)
        {
            var row      = new Row();
            var trueType = NHibernateProxyHelper.GetClassWithoutInitializingProxy(o);
            var mapping  = Cfg.GetClassMapping(trueType);

            row.Add(KV("Type", BuildTypeLink(trueType)));
            if (mapping == null)
            {
                // not a mapped type
                if (o is object[])
                {
                    row.AddRange(ConvertObjectArray((object[])o, model));
                }
                else
                {
                    row.Add(KV("Value", HttpUtility.HtmlEncode(Convert.ToString(o))));
                }
            }
            else
            {
                var idProp = mapping.IdentifierProperty;
                var id     = idProp.GetGetter(trueType).Get(o);
                row.Add(KV(idProp.Name, Convert.ToString(id)));
                row.AddRange(mapping.PropertyClosureIterator
                             .SelectMany(p => ConvertProperty(o, trueType, p, model)));
            }
            return(row);
        }