Server Error in '/' Application.

The method 'First' can only be used as a final query operation. Consider using the method 'FirstOrDefault' in this instance instead.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NotSupportedException: The method 'First' can only be used as a final query operation. Consider using the method 'FirstOrDefault' in this instance instead.

Source Error:


Line 149:
Line 150:
Line 151:                                var listingdata = ToView.ReEFBLL.Queries.Listing.GetAVGListingLocation(area.Id);
Line 152:
Line 153:                                if (listingdata != null)

Source File: i:\Source\Projects\ADELELUCAS\toview.v1\Websites\Realestate\RELEASE\mapping.aspx.cs    Line: 151

Stack Trace:


[NotSupportedException: The method 'First' can only be used as a final query operation. Consider using the method 'FirstOrDefault' in this instance instead.]
   System.Data.Entity.Core.Objects.ELinq.FirstTranslator.TranslateUnary(ExpressionConverter parent, DbExpression operand, MethodCallExpression call) +97
   System.Data.Entity.Core.Objects.ELinq.MethodCallTranslator.TypedTranslate(ExpressionConverter parent, MethodCallExpression linq) +135
   System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq) +141
   System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateIntoCanonicalFunction(String functionName, Expression Expression, Expression[] linqArguments) +75
   System.Data.Entity.Core.Objects.ELinq.MethodCallTranslator.TypedTranslate(ExpressionConverter parent, MethodCallExpression linq) +184
   System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq) +141
   System.Data.Entity.Core.Objects.ELinq.MemberInitTranslator.TypedTranslate(ExpressionConverter parent, MemberInitExpression linq) +361
   System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq) +141
   System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateLambda(LambdaExpression lambda, DbExpression input) +119
   System.Data.Entity.Core.Objects.ELinq.OneLambdaTranslator.Translate(ExpressionConverter parent, MethodCallExpression call, DbExpression& source, DbExpressionBinding& sourceBinding, DbExpression& lambda) +133
   System.Data.Entity.Core.Objects.ELinq.SelectTranslator.Translate(ExpressionConverter parent, MethodCallExpression call) +56
   System.Data.Entity.Core.Objects.ELinq.MethodCallTranslator.TypedTranslate(ExpressionConverter parent, MethodCallExpression linq) +135
   System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq) +141
   System.Data.Entity.Core.Objects.ELinq.UnarySequenceMethodTranslator.Translate(ExpressionConverter parent, MethodCallExpression call) +151
   System.Data.Entity.Core.Objects.ELinq.MethodCallTranslator.TypedTranslate(ExpressionConverter parent, MethodCallExpression linq) +135
   System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq) +141
   System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.Convert() +21
   System.Data.Entity.Core.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable`1 forMergeOption) +295
   System.Data.Entity.Core.Objects.<>c__DisplayClass7.<GetResults>b__6() +38
   System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction(Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess) +459
   System.Data.Entity.Core.Objects.<>c__DisplayClass7.<GetResults>b__5() +203
   System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func`1 operation) +230
   System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) +354
   System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0() +30
   System.Data.Entity.Internal.LazyEnumerator`1.MoveNext() +39
   ToView.ReEFBLL.Queries.Listing.GetAVGListingLocation(Int32 areaid) in G:\Development\PETER\Projects\ADELELUCAS\toview.v1\ToView.ReEFBLL\Queries\ListingQuery.cs:626
   mapping.Page_Load(Object sender, EventArgs e) in i:\Source\Projects\ADELELUCAS\toview.v1\Websites\Realestate\RELEASE\mapping.aspx.cs:151
   System.Web.UI.Control.OnLoad(EventArgs e) +106
   System.Web.UI.Control.LoadRecursive() +68
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3785


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.4087.0