Home

Please add XXX.OrderByDescending( x => ....).Take(10) to the right click pop up menu

edited May 2012
Hi Joe, Would you consider to just add

TableObjects.OrderByDescending( x=> ...).Take(10)

in the pop up menu when right click on Table Object?

Many times when I open LINQPad I need to investigate the latest logged items.

Comments

  • edited May 2012
    Yes, at some stage, I should allow users to customize that menu.

    In the meantime, you could write the following snippet. Save it to My Documents\LINQPad Snippets\od.snippet (where "od" is the desired shortcut). Then press od TAB and it will bring up a list of tables to choose from.
    <?xml version="1.0" encoding="utf-8" ?>
    <CodeSnippets xmlns='http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet' >
    	<CodeSnippet Format="1.0.0">
    		<Header>
    			<Title>OrderByDescending(...)Take(10)</Title>
    			<Shortcut>od</Shortcut>
    			<Description>OrderByDescending(...)Take(10)</Description>
    			<SnippetTypes>
    				<SnippetType>Expansion</SnippetType>
    			</SnippetTypes>
    		</Header>
    		<Snippet>
    			<Declarations>
    				<Literal>
    					<ID>sequence</ID>
    					<ToolTip>Sequence or collection to query</ToolTip>
    					<Default>querySource</Default>
    				</Literal>
    			</Declarations>
    			<Coooode Language='csharp'>$sequence$.OrderByDescending(x => x$end$).Take(10)</Coooode >
    		</Snippet>
    	</CodeSnippet>
    </CodeSnippets>
    Change Coooode to Code (the forum doesn't let me use Code as a tag for obvious reasons).

    Would that work for you?
  • Yes, this works very good!
  • Joe,

    Where can I find documentation on how to create my own snippets (like you have done above)?

    When I run a query against my company's production database, the corporate requirement is to include the nolock hint. So, I want a snippet that will paste the following (C# statement) into the query window:

    using (var txn = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions
    {
    IsolationLevel = IsolationLevel.ReadUncommitted
    }
    ))
    {

    }

    I realize that you may reply with the snippet for me (as you did above), but I'm hoping that there is some documentation so I can do others.
  • The schema for snippets is identical to Visual Studio's:

    http://msdn.microsoft.com/en-us/library/ms165392(v=vs.80).aspx

    There are also third-party tools to help create snippets.
Sign In or Register to comment.