Esempio n. 1
0
        private static Type CreateType(string name, System.Data.IDataReader reader, string extraColumns)
        {
            string columns = string.Join("#", Enumerable.Range(0, reader.FieldCount)
                                         .Select(i => string.Format("{0},{1},{2}",
                                                                    reader.GetFieldType(i).Name,
                                                                    i,
                                                                    reader.GetName(Conversions.ToInteger(i))))
                                         .ToArray());

            if (extraColumns != null && extraColumns.Length > 0)
            {
                columns += extraColumns;// #Integer,~key1,Prueba#String,~key2,PruebaS
            }
            return(SmallXmlSerializer.CreateType(name, FieldInfo.FromString(columns)));
        }
Esempio n. 2
0
 public static SmallXmlSerializer CreateAndFillSerializer(string name, DbContext context, string queryName, ExtensionPoint extensionPoint, string extraColumns, QueryBuilder queryBuilder)
 {
     using (var __repo = new Dal.Repositories.DynamicRepository(context))
     {
         using (var __reader = __repo.ExecuteNamedReader(queryName, queryBuilder))
         {
             string __name  = string.Format("{0}_{1}", name, "SqlDQ");
             Type   __otype = SmallXmlSerializer.GetTypeByName(__name);
             if (__otype == null)
             {
                 __otype = CreateType(name, __reader, extraColumns);
             }
             var __list = new List <object>();
             while (__reader.Read())
             {
                 __list.Add(Activator.CreateInstance(__otype, new object[] { __reader, extensionPoint }));
             }
             return(new SmallXmlSerializer(__otype).SetValues(__list));
         }
     }
 }