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 7408225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:52:36+00:00 2026-05-29T05:52:36+00:00

I have a query made using linq to SQL which result will be shown

  • 0

I have a query made using linq to SQL which result will be shown in a datagridview with sorting and filtering options.

public IQueryable RegresaDepositosBancarios()
        {
            var depositos = from d in context.depositos_bancarios
                            where d.Aplicado == false
                            orderby d.FechaDeposito ascending
                            select new
                            {
                                d.IDDeposito,
                                d.cuentas_bancarias.Nombre,
                                d.Monto,
                                d.FechaDeposito,
                                d.Observaciones
                            };
            return depositos    ;
        }

Later in my code I set the datasource to use previous result.

var depositos = operaciones.RegresaDepositosBancarios();
dataGrid_depositos.DataSource = depositos;

As you can see I’m returning and IQueryable of anonymous type and I can’t perform sorting or filtering over this. I read that you can implement a custom function to convert IQueryable to DataView and then use the RowFilter property, is this the more efficient way of doing it? Could be better to return other type in my function?

Any suggestions are welcome

  • 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-05-29T05:52:36+00:00Added an answer on May 29, 2026 at 5:52 am

    You should change the return type from IQueryable to IEnumerable<dynamic>, then you can do something like:

     var over100 = RegresaDepositosBancarios()
        .Where(d => d.Monto > 100);
    

    I think you could also code it this way (however I don’t normally use from so am not sure)

     var over100 = from d in RegresaDepositosBancarios()
        where d.Montho > 100;
    

    Here’s a test program.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    
    namespace ClassLibrary1
    {
    public class Class1
    {
        public int A;
        public int B;
    }
    
    public class Test
    {
        public static IEnumerable<dynamic> Build()
        {
            var list = new List<Class1>();
            list.Add(new Class1() { A = 10, B = 100 });
            list.Add(new Class1() { A = 200, B = 2000 });
    
            return list
                .OrderBy(e => e.B)
                .Select(e => new { A1 = e.A, B2 = e.B });
        }
    
        public static IEnumerable<dynamic> Filter()
        {
            return Build()
                .Where(e => e.A1 > 100);
        }
    
        static void Main()
        {
            foreach (dynamic e in Filter())
                Console.WriteLine("A1={0}, B2={1}", e.A1, e.B2);
        }
    }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this query in sql server 2000: select pwdencrypt('AAAA') which outputs an encrypted
I am trying to bind to the results of a Linq-To-SQL query, which I
I am returning two lists from the database using LINQ to SQL compiled query.
I have a LINQ query which is attempting to get all of the distinct
I have an access database, with a query made. I need to automate it
I have a huge query that is being made dynamically, but I want the
I am using in C# MYsql .I have query that works if I run
I have a query that looks like this: public IList<Post> FetchLatestOrders(int pageIndex, int recordCount)
This is a follow on from another question i made I have this query
I'm constructing a SQL query for a business report. I need to have both

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.