dbelmont / ExpressionBuilder

A library that provides a simple way to create lambda expressions to filter lists and database queries.
Apache License 2.0
372 stars 105 forks source link

GetCustomSupportedTypes throws NullReferenceException #52

Open aldrashan opened 5 years ago

aldrashan commented 5 years ago

GetCustomSupportedTypes (ExpressionBuilder.Helpers.OperationHelper) throws NullReferenceException when you don't have the config section defined in your project.

foreach (var supportedType in _settings.SupportedTypes) { if (supportedType.Type != null) { TypeGroups[supportedType.TypeGroup].Add(supportedType.Type); } }

This foreach loop throws an exception since _settings.SupportedTypes is null.

Suggested change: In ExpressionBuilder.Configuration.Settings class, LoadSettings method:

var configSection = ConfigurationManager.GetSection(ExpressionBuilderConfig.SectionName) as ExpressionBuilderConfig; if (configSection == null) { settings.SupportedTypes = new List(); return; }

I've added the part in bold. This seems to fix the problem.