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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:23:13+00:00 2026-06-10T13:23:13+00:00

I have the following code: public IList<Reference.Grid> GetGrid(string pk) { return ( from d

  • 0

I have the following code:

public IList<Reference.Grid> GetGrid(string pk)
{
    return (
        from d in _referenceRepository.GetPk(pk)
        select new Reference.Grid
        {
            PartitionKey = d.PartitionKey,
            RowKey = d.RowKey,
            Value = d.Value,
            Order = d.Order
        })
}

I am new to LINQ but I understand there are two ways I can write a select. Can someone help by telling me how I can rewrite this the other way. Also are there any differences and which way do people most often use?

  • 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-10T13:23:15+00:00Added an answer on June 10, 2026 at 1:23 pm

    The two ways you have mentioned are method- and query-syntax. You have used query-syntax.

    This is the same in method syntax:

    public IList<Reference.Grid> GetGrid(string pk)
    {
        return (
        _referenceRepository.GetPk(pk)
        .Select(d => new Reference.Grid
        {
            PartitionKey = d.PartitionKey,
            RowKey = d.RowKey,
            Value = d.Value,
            Order = d.Order
        })).ToList();
    }
    

    Note that i’ve changed it to use ToList to create a List<Reference.Grid>. otherwise it would be an IEnumerable<Reference.Grid>.

    Also are there any differences and which way do people most often use?

    Use what is most readable and works. There are some methods not supported in query-syntax.

    MSDN: LINQ Query Syntax versus Method Syntax (C#)

    Which LINQ syntax do you prefer? Fluent or Query Expression

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

Sidebar

Related Questions

I have the following code: public IEnumerable<Content.Grid> DetailsBase(string pk) { var data = contentRepository.GetPk(pk);
I have the following code: public IList<ProductionRuns> List() { var Shows3Months = (from s
I have the following code: public static IList<SortOption> SortValues() { var sortValues = (from
I have following code public class TEST { public static void main(String arg[]){ try
i have the following code: public static void Serialize() { List<string> dirs = FileHelper.GetFilesRecursive(fileDirectoryPath);
I have the following code: public class AppDomainArgs : MarshalByRefObject { public string myString;
I have the following code: public List<IWFResourceInstance> FindStepsByType(IWFResource res) { List<IWFResourceInstance> retval = new
Here I have the following bit of code: private IList<IState> _states = new List<IState>();
I have the following example-class: public class MyClass<T> { public IList<T> GetAll() { return
I have the following code: public IList<T_CLIENT> Get_All_Obj() { try { IList<T_CLIENT> LesListe; using

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.