private static void WriteReport(IOrderedEnumerable <ReportModel> report4, string reportFileNameWithoutExtension) { var reportResult = report4.Aggregate("tenor, portfolioid, value\r\n", (current, model) => current + model.ToString()); // Assuming that for brevity, the output file path can be specified through the config file, rather than taking human input var outputFile = Path.Combine(ConfigurationManager.AppSettings["OutputFilePath"] ?? ".\\", String.Concat(reportFileNameWithoutExtension, ".txt")); File.WriteAllText(outputFile, reportResult); }
protected IQueryable <TReportObject> DecorateQuery(IQueryable <TReportObject> query) { IOrderedEnumerable <QueryDecorator <TReportObject> > source = from decorator in this.queryDecorators where !this.IsExpressionEnforced || decorator.IsEnforced orderby decorator.QueryOrder select decorator; return(source.Aggregate(query, (IQueryable <TReportObject> current, QueryDecorator <TReportObject> decorator) => decorator.GetQuery(current))); }
/// <summary> /// Gets all property names of an object that are decorated with ViewComplexPropertyAttribute or ViewComplexPropertyForeignKeyAttribute. /// </summary> /// <param name="properties">A list of PropertyInfo object to query</param> /// <returns>string[]</returns> public static string[] GetComplexPropertyNames(IOrderedEnumerable <PropertyInfo> properties) { return(properties.Aggregate <PropertyInfo, List <string> >(new List <string>(), (List <string> sum, PropertyInfo property) => { if (property.GetCustomAttributes(typeof(ViewComplexPropertyAttribute), false).Length > 0) { var fkAttribute = (property.GetCustomAttributes(typeof(ViewComplexPropertyForeignKeyAttribute), false) as ViewComplexPropertyForeignKeyAttribute[]).SingleOrDefault(); if (fkAttribute != null) { sum.Add(fkAttribute.ForPropertyName); } else { sum.Add(property.Name); } } return sum; }).ToArray()); }