You must Sign In to post a response.
  • Category: LINQ

    How to fetch specific feilds from table in entity framework

    Hi All,

    How to fetch specific columns data from table and return in to List<> in C# using entity frame work
  • #754074
    Hai Rahul,
    To fetch the data from the entity Framework by using the Stored procedure or List, you need to first get the list collection.
    Once you get the list collection, you can filter the data for the specific column.
    Below is the code snippet which can be helpful to you to understand;

    var res = pbe.ftclngroup.Select(a => a.Name).ToList();

    The above code will give you the list of Name column.
    Hope it will be helpful to you.

    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)

  • #754118
    if you have a model created withh those fields which you want to retrieve using the entityframework. Then you can directly use the .ToList<modelName>. This will assign the selected columns of the model the intended values.
    Miss. Jain
    Microsoft Certified Technology Specialist in .Net

  • #754154
    Generally the ORM tool like Entity framework return the complete table columns and based on our requirement we have to filter the tables.

    So you can use the LINQ in order to filter the value from current context.

    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM

  • Sign In to post your comments