Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8247401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:50:15+00:00 2026-06-07T22:50:15+00:00

I’d like to filter the result that after Linq query. and make it to

  • 0

I’d like to filter the result that after Linq query.

and make it to List() or Array().

Here is my code,

//for test, filter is always true
bool filter = true;

OrdersRepository ordersRepository = new OrdersRepository();

var productInQuery = ordersRepository.ProductIn;
var productOutQuery = ordersRepository.ProductOut;
var productQuery = ordersRepository.Product;
var orderInfoQuery = ordersRepository.OrderInfo;

var result = (from p in productInQuery
      join o in orderInfoQuery on p.refNo equals o.refNo
      join x in productQuery on p.productNo equals x.no
      join t in productOutQuery on p.no equals t.productInNo into productIn
      from t in productIn.DefaultIfEmpty()
      orderby o.processDate descending
      select new reportModel
      {
          yourRef = o.yourRefNo,
          modelNo = x.modelNo,
          mfgNo = p.mfgNo,
          serialNo = p.serialNo,
          poNo = p.poNo,
          lbs =  p.lbs,
          width = p.width,
          height = p.height,
          depth = p.depth,
          qty = p.qty,
          dateIn = o.processDate,
          dateOut = (from m in orderInfoQuery where m.refNo == t.refNo select m.processDate).FirstOrDefault(),
          etaDate = (from w in orderInfoQuery where w.refNo == t.refNo select w.eta).FirstOrDefault()
      });

// Filter one more time
if (filter)
{
    List<reportModel> a = (from q in result
         where q.etaDate >= new DateTime(2012, 5, 20)
         select q).ToList();

    //var a = result.Where(q => q.etaDate >= new DateTime(2012, 5, 20)).ToList(); //I tried this too, but it does not work either.
}
else
{
    var a = result.ToList();
}

When run the above code, an error message occur.

Specified method is not supported.

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: Specified method is not supported.

Source Error: 


Line 64:                  */
Line 65: 
Line 66:                 var a = result.Where(q => q.etaDate >= new DateTime(2012, 5, 20)).ToList();
Line 67:             }
Line 68:             else

Source File: WebUI\Controllers\TestController.cs    Line: 66 

Stack Trace: 


[NotSupportedException: Specified method is not supported.]
   MySql.Data.Entity.SqlGenerator.Visit(DbApplyExpression expression) +28
   System.Data.Common.CommandTrees.DbApplyExpression.Accept(DbExpressionVisitor`1 visitor) +23
   MySql.Data.Entity.SqlGenerator.VisitInputExpression(DbExpression e, String name, TypeUsage type) +35
   MySql.Data.Entity.SelectGenerator.VisitInputExpressionEnsureSelect(DbExpression e, String name, TypeUsage type) +21
   MySql.Data.Entity.SelectGenerator.Visit(DbProjectExpression expression) +38
   System.Data.Common.CommandTrees.DbProjectExpression.Accept(DbExpressionVisitor`1 visitor) +23
   MySql.Data.Entity.SqlGenerator.VisitInputExpression(DbExpression e, String name, TypeUsage type) +35
   MySql.Data.Entity.SelectGenerator.VisitInputExpressionEnsureSelect(DbExpression e, String name, TypeUsage type) +21
   MySql.Data.Entity.SelectGenerator.Visit(DbFilterExpression expression) +37
   System.Data.Common.CommandTrees.DbFilterExpression.Accept(DbExpressionVisitor`1 visitor) +23
   MySql.Data.Entity.SqlGenerator.VisitInputExpression(DbExpression e, String name, TypeUsage type) +35
   MySql.Data.Entity.SelectGenerator.VisitInputExpressionEnsureSelect(DbExpression e, String name, TypeUsage type) +21
   MySql.Data.Entity.SelectGenerator.Visit(DbProjectExpression expression) +38
   System.Data.Common.CommandTrees.DbProjectExpression.Accept(DbExpressionVisitor`1 visitor) +23
   MySql.Data.Entity.SqlGenerator.VisitInputExpression(DbExpression e, String name, TypeUsage type) +35
   MySql.Data.Entity.SelectGenerator.VisitInputExpressionEnsureSelect(DbExpression e, String name, TypeUsage type) +21
   MySql.Data.Entity.SelectGenerator.Visit(DbProjectExpression expression) +38
   System.Data.Common.CommandTrees.DbProjectExpression.Accept(DbExpressionVisitor`1 visitor) +23
   MySql.Data.Entity.SqlGenerator.VisitInputExpression(DbExpression e, String name, TypeUsage type) +35
   MySql.Data.Entity.SelectGenerator.VisitInputExpressionEnsureSelect(DbExpression e, String name, TypeUsage type) +21
   MySql.Data.Entity.SelectGenerator.Visit(DbSortExpression expression) +63
   System.Data.Common.CommandTrees.DbSortExpression.Accept(DbExpressionVisitor`1 visitor) +23
   MySql.Data.Entity.SqlGenerator.VisitInputExpression(DbExpression e, String name, TypeUsage type) +35
   MySql.Data.Entity.SelectGenerator.VisitInputExpressionEnsureSelect(DbExpression e, String name, TypeUsage type) +21
   MySql.Data.Entity.SelectGenerator.Visit(DbProjectExpression expression) +38
   System.Data.Common.CommandTrees.DbProjectExpression.Accept(DbExpressionVisitor`1 visitor) +23
   MySql.Data.Entity.SelectGenerator.GenerateSQL(DbCommandTree tree) +60
   MySql.Data.MySqlClient.MySqlProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree) +334
   System.Data.Common.DbProviderServices.CreateCommandDefinition(DbCommandTree commandTree) +147
   System.Data.EntityClient.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree) +526

[EntityCommandCompilationException: An error occurred while preparing the command definition. See the inner exception for details.]
   System.Data.EntityClient.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree) +1329
   System.Data.EntityClient.EntityProviderServices.CreateCommandDefinition(DbProviderFactory storeProviderFactory, DbCommandTree commandTree) +97
   System.Data.EntityClient.EntityProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree) +198
   System.Data.Common.DbProviderServices.CreateCommandDefinition(DbCommandTree commandTree) +147
   System.Data.Objects.Internal.ObjectQueryExecutionPlan.Prepare(ObjectContext context, DbQueryCommandTree tree, Type elementType, MergeOption mergeOption, Span span, ReadOnlyCollection`1 compiledQueryParameters) +397
   System.Data.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable`1 forMergeOption) +696
   System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) +149
   System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() +44
   System.Data.Entity.Internal.Linq.InternalQuery`1.GetEnumerator() +40
   System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator() +40
   System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +315
   System.Linq.Enumerable.ToList(IEnumerable`1 source) +58
   BseWms.WebUI.Controllers.TestController.dateTest() in C:\Users\mark\Documents\Visual Studio 2010\Projects\BseWms\BseWms.WebUI\Controllers\TestController.cs:66
   lambda_method(Closure , ControllerBase , Object[] ) +62
   System.Web.Mvc.<>c__DisplayClass1.<WrapVoidAction>b__0(ControllerBase controller, Object[] parameters) +17
   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +208
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
   System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
   System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
   System.Web.Mvc.Controller.ExecuteCore() +116
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
   System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
   System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
   System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8970349
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

and the reportModel class.

public class reportModel
{
    public string yourRef {get; set;}
    public string modelNo {get; set;}
    public string mfgNo {get; set;}
    public string serialNo {get; set;}
    public string poNo {get; set;}
    public Nullable<float> lbs { get; set; }
    public Nullable<float> width { get; set; }
    public Nullable<float> height { get; set; }
    public Nullable<float> depth { get; set; }
    public int qty {get; set;}
    public Nullable<DateTime> dateIn { get; set; }
    public Nullable<DateTime> dateOut { get; set; }
    public Nullable<DateTime> etaDate { get; set; }
}

what’s wrong with this code? @.@;

anybody know, please please advice me.

Thanks

[Edit]

@Tyrsius

I tried as your advice, but same error occur.

var thedate = new DateTime(2012, 5, 20);
List<reportModel> a = (from q in result
                       where q.etaDate >= thedate
                       select q).ToList();

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T22:50:17+00:00Added an answer on June 7, 2026 at 10:50 pm

    This bit here

    List<reportModel> a = (from q in result 
        where q.etaDate >= new DateTime(2012, 5, 20) select q).ToList();
    

    Is illegal because EF needs to translate this into SQL, and you can’t pass in object constructor like new Datetime(). The solution is simple: construct the object before trying to use it in the query

    var date = new DateTime(2012, 5, 20);
    List<reportModel> a = (from q in result 
        where q.etaDate >= date select q).ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I would like to count the length of a string with PHP. The string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to run a str_replace or preg_replace which looks for certain words
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.