Code
var results = db.Database.SqlQuery<HeadLineResult>(sql).ToList();
Cause: This was because the class had a property of type short which I had incorrectly declared as int
Error message
Exception has been thrown by the target of an invocation.
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
at DevExpress.ExpressApp.DC.Internal.PropertyInfoInternal.GetValue(Object obj)
at DevExpress.ExpressApp.DC.Internal.MemberInfoInternalWrapper.GetValue(Object obj)
at DevExpress.ExpressApp.DC.XafMemberInfo.GetValue(Object obj)
at DevExpress.ExpressApp.PropertyCollectionSource.CreateCollection()
at DevExpress.ExpressApp.CollectionSourceBase.ResetCollection(Boolean updateObjectsInCriteria)
at DevExpress.ExpressApp.CollectionSourceBase.InitCollection()
at DevExpress.ExpressApp.CollectionSourceBase.get_Collection()
at DevExpress.ExpressApp.ListView.RefreshEditorDataSource()
at DevExpress.ExpressApp.ListView.set_Editor(ListEditor value)
at DevExpress.ExpressApp.ListView.LoadModelCore()
at DevExpress.ExpressApp.View.LoadModel()
at DevExpress.ExpressApp.View.SetModel(IModelView model)
at DevExpress.ExpressApp.XafApplication.CreateListView(String listViewId, IModelListView modelListView, CollectionSourceBase collectionSource, Boolean isRoot, ListEditor listEditor)
at DevExpress.ExpressApp.XafApplication.CreateListView(String listViewId, CollectionSourceBase collectionSource, Boolean isRoot)
at DevExpress.ExpressApp.Editors.ListPropertyEditor.CreateListView()
at DevExpress.ExpressApp.Editors.ListPropertyEditor.InitializeFrame()
at DevExpress.ExpressApp.Editors.ListPropertyEditor.CreateControlCore()
at DevExpress.ExpressApp.Editors.ViewItem.CreateControl()
at DevExpress.ExpressApp.Win.Layout.WinLayoutManager.GetControl(ViewItem viewItem, String name, Boolean forceControlCreation)
at DevExpress.ExpressApp.Win.Layout.WinLayoutManager.controlItem_QueryControl(Object sender, QueryControlEventArgs e)
at DevExpress.ExpressApp.Win.Layout.XafLayoutControlItem.RaiseQueryControl()
at DevExpress.ExpressApp.Win.Layout.XafLayoutControlItem.EnsureControl()
at DevExpress.ExpressApp.Win.Layout.XafLayoutControlItem.RaiseShowHide(Boolean visible)
at DevExpress.XtraLayout.BaseLayoutItem.SetVisible(Boolean lVisible)
at DevExpress.XtraLayout.BaseLayoutItem.UpdateChildren(Boolean visible)
at DevExpress.XtraLayout.LayoutControlItem.UpdateChildren(Boolean visible)
at DevExpress.XtraLayout.LayoutGroup.UpdateChild(BaseLayoutItem item, Boolean visible)
at DevExpress.XtraLayout.LayoutGroup.UpdateChildren(Boolean visible)
at DevExpress.XtraLayout.LayoutGroup.UpdateChild(BaseLayoutItem item, Boolean visible)
at DevExpress.XtraLayout.LayoutGroup.UpdateChildren(Boolean visible)
at DevExpress.XtraLayout.LayoutGroup.UpdateChild(BaseLayoutItem item, Boolean visible)
at DevExpress.XtraLayout.LayoutGroup.UpdateChildren(Boolean visible)
at DevExpress.XtraLayout.LayoutControlImplementor.UpdateRoot()
at DevExpress.XtraLayout.LayoutControlImplementor.InvalidateRootOffsetControlsAndScrolls()
at DevExpress.XtraLayout.LayoutControlImplementor.Invalidate()
at DevExpress.XtraLayout.LayoutControl.DevExpress.XtraLayout.ILayoutControl.Invalidate()
at DevExpress.XtraLayout.BaseLayoutItem.Invalidate()
at DevExpress.XtraLayout.LayoutGroup.Invalidate()
at DevExpress.XtraLayout.BaseLayoutItem.ComplexUpdate(Boolean shouldUpdateViewInfo, Boolean shouldResize, Boolean shouldArrangeTextSize)
at DevExpress.XtraLayout.BaseLayoutItem.ComplexUpdate(Boolean shouldUpdateViewInfo, Boolean shouldResize)
at DevExpress.XtraLayout.LayoutItemContainer.EndUpdate()
at DevExpress.XtraLayout.LayoutItemContainer.EndChangeUpdate()
at DevExpress.XtraLayout.LayoutDesignerMethodsProvider.DevExpress.XtraLayout.ILayoutDesignerMethods.EndChangeUpdate()
at DevExpress.XtraLayout.LayoutControlImplementor.ProcessLookAndFeelStyleChanged()
at DevExpress.XtraLayout.LayoutControlImplementor.OnLookAndFeelStyleChanged(Object sender, EventArgs e)
at DevExpress.XtraLayout.LayoutControlImplementor.EndInitCore()
at DevExpress.XtraLayout.LayoutControlImplementor.set_UpdatedCount(Int32 value)
at DevExpress.XtraLayout.LayoutControlImplementor.EndInit()
at DevExpress.XtraLayout.LayoutControl.EndInit()
at DevExpress.ExpressApp.Win.Layout.WinLayoutManager.LayoutControls(IModelNode layoutNode, ViewItemsCollection viewItems)
at DevExpress.ExpressApp.CompositeView.CreateControlsCore()
at DevExpress.ExpressApp.View.CreateControls()
at DevExpress.ExpressApp.Win.Templates.ViewSiteManager.EnsureViewControl()
at DevExpress.ExpressApp.Win.Templates.ViewSiteManager.FillViewSite()
at DevExpress.ExpressApp.Win.Templates.ViewSiteManager.OnViewChanged()
at DevExpress.ExpressApp.Win.Templates.ViewSiteManager.SetView(View view)
at DevExpress.ExpressApp.Win.Templates.Ribbon.DetailRibbonFormV2.DevExpress.ExpressApp.Templates.IFrameTemplate.SetView(View view)
at DevExpress.ExpressApp.Frame.SetTemplateView(View view)
at DevExpress.ExpressApp.Frame.SetView(View view, Boolean updateControllers, Frame sourceFrame, Boolean disposeOldView)