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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:40:02+00:00 2026-05-28T06:40:02+00:00

this is my code… but i need select only column to display in my

  • 0

this is my code… but i need select only column to display in my Datagridview.
I Need the code to select only some columns.. example

Select{t => t.usu_Login, t => t.usu_Login}

public List<tb_usuario> Get(FilterDefinition filter)
{

     var contexto = new indNET_Entities();

     IQueryable<tb_usuario> Consulta = contexto.tb_usuario.AsQueryable<tb_usuario>()
                                                        .Where(t => t.usu_Ativo == 1)
                                                        .OrderBy(t => t.usu_Login);


     return Consulta.ToList();

}
  • 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-28T06:40:02+00:00Added an answer on May 28, 2026 at 6:40 am

    If you only want a limited number of columns and you intend to pass the result out of the method, first declare a concrete type to describe the elements.

    public class UsuarioData
    {
         public string UsuLogin { get; set; } // or whatever
         public string UsuName { get; set; }  // or whatever
    }
    

    Then you can use this in the return type for the method

    public List<UsuarioData> Get(...) 
    

    And finally, use the type in your select.

    var consulta = contexto.tb_usuario.Where(whatever).OrderBy(whatever)
                       .Select(t => new UsuarioData
                                    {
                                         UsuLogin = t.usu_login,
                                         UsuName = t.usu_name
                                    }
                               );
    
    return consulta.ToList();
    

    And, of course, your callers should expect to get this as the result (or just use type inference with var).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this code was just working! but for some reason it stopped to work now.
This code does not seem to compile, I just need to write something to
This code produces a FileNotFoundException, but ultimately runs without issue: void ReadXml() { XmlSerializer
This code is ment to download the source code of an html file but
This code is reading from mysql db tables and should return few names. But
This code runs perfectly on Java but when I run this on Android platform,
This code can be used to select the first ten records from a table
This code should works, but in fact the span is not displayed : <a
This code has no errors in it, but when i click the button nothing
this code run firefox , but error on ie why ? please help me.

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.