/// <summary> /// return total list confidential reasons /// </summary> public static IEnumerable <TransfersConfidentialRow> GetConfidentialReason(PollutantTransfersSearchFilter filter) { DataClassesPollutantTransferDataContext db = getPollutantTransferDataContext(); // apply filter for confidential, do not include the pollutant itself ParameterExpression param = Expression.Parameter(typeof(POLLUTANTTRANSFER), "s"); Expression exp = LinqExpressionBuilder.GetLinqExpressionPollutantTransfersConfidential(filter, param, false); Expression <Func <POLLUTANTTRANSFER, bool> > lambda = Expression.Lambda <Func <POLLUTANTTRANSFER, bool> >(exp, param); var reason0 = db.POLLUTANTTRANSFERs.Where(lambda); var reason1 = from p in reason0 group p by new { p.ConfidentialCode }; var reason2 = from p in reason1 select new { code = p.Select(x => x.ConfidentialCode).First(), count = p.Count() }; // build result List <TransfersConfidentialRow> result = new List <TransfersConfidentialRow>(); foreach (var v in reason2) { result.Add(new TransfersConfidentialRow(v.code, v.count)); } return(result.OrderBy(x => x.Code)); }
/// <summary> /// return total list confidential pollutants /// </summary> public static IEnumerable <TransfersConfidentialRow> GetConfidentialPollutant(PollutantTransfersSearchFilter filter) { DataClassesPollutantTransferDataContext db = getPollutantTransferDataContext(); // apply filter for confidential, include pollutants ParameterExpression param = Expression.Parameter(typeof(POLLUTANTTRANSFER), "s"); Expression exp = LinqExpressionBuilder.GetLinqExpressionPollutantTransfersConfidential(filter, param, true); Expression <Func <POLLUTANTTRANSFER, bool> > lambda = Expression.Lambda <Func <POLLUTANTTRANSFER, bool> >(exp, param); // sum up facilities var pollutant0 = db.POLLUTANTTRANSFERs.Where(lambda); var pollutant1 = from p in pollutant0 group p by new { p.PollutantCode }; var pollutant2 = from p in pollutant1 select new { code = p.Select(x => x.PollutantCode).First(), count = p.Count() }; // build result List <TransfersConfidentialRow> result = new List <TransfersConfidentialRow>(); foreach (var v in pollutant2) { result.Add(new TransfersConfidentialRow(v.code, v.count)); } return(result); }
/// <summary> /// get lambda for confidential pollutant transfers /// </summary> private static Expression <Func <POLLUTANTTRANSFER, bool> > getPollutantTransfersConfidentialLambda(DataClassesPollutantTransferDataContext db, IndustrialActivitySearchFilter filter, bool includePollutant) { ParameterExpression param = Expression.Parameter(typeof(POLLUTANTTRANSFER), "s"); PollutantTransfersSearchFilter filterTransfers = FilterConverter.ConvertToPollutantTransfersSearchFilter(filter); Expression exp = LinqExpressionBuilder.GetLinqExpressionPollutantTransfersConfidential(filterTransfers, param, includePollutant); Expression <Func <POLLUTANTTRANSFER, bool> > lambda = Expression.Lambda <Func <POLLUTANTTRANSFER, bool> >(exp, param); return(lambda); }
/// <summary> /// return true if confidentiality might effect result /// </summary> public static bool IsAffectedByConfidentiality(PollutantTransfersSearchFilter filter) { DataClassesPollutantTransferDataContext db = getPollutantTransferDataContext(); // apply filter for confidential, do not include the pollutant itself ParameterExpression param = Expression.Parameter(typeof(POLLUTANTTRANSFER), "s"); Expression exp = LinqExpressionBuilder.GetLinqExpressionPollutantTransfersConfidential(filter, param, false); Expression <Func <POLLUTANTTRANSFER, bool> > lambda = Expression.Lambda <Func <POLLUTANTTRANSFER, bool> >(exp, param); return(db.POLLUTANTTRANSFERs.Any(lambda)); }