﻿<?xml version="1.0"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Create A Query Interceptor for an EntitySet</Title>
      <Shortcut>qi</Shortcut>
      <Description>
        This snippet will help you create a QueryInterceptor for an EntitySet
      </Description>
      <Author> Phani Raj </Author>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>name</ID>
          <ToolTip>The Entity Set whose Queries you want to intercept</ToolTip>
          <Default>"EntitySetName"</Default>
        </Literal>
      </Declarations>
      <Code Language="CSharp">
        <![CDATA[
  /// <summary>
  /// This Query Interceptor is called whenever the EntitySet "$name$" is Queried
  /// </summary>
  /// <returns>
  /// An expression that filters out entities of EntitySet "$name$" , based on some user logic
  /// </returns>
	[QueryInterceptor("$name$")]
	public Expression<Func<$name$, bool>> OnQuery$name$()
	{
		//Filter Expression goes here
		return ($name$Entity) => true;
	}
]]>
      </Code>
    </Snippet>
  </CodeSnippet>
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Create A Change Interceptor for an EntitySet</Title>
      <Shortcut>ci</Shortcut>
      <Description>
        This snippet will help you create a ChangeInterceptor for an EntitySet
      </Description>
      <Author> Phani Raj </Author>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>name</ID>
          <ToolTip>The Entity Set whose Changes you want to intercept</ToolTip>
          <Default>"EntitySetName"</Default>
        </Literal>
      </Declarations>
      <Code Language="CSharp">
        <![CDATA[
  /// <summary>
  /// This Change Interceptor is called whenever an entity of the EntitySet "$name$" is updated
  /// </summary>
  /// <param name="$name$Entity">The Entity that is being updated</param>
  /// <param name="updateAction">The operation that is being performed on the entity</param>
	[ChangeInterceptor("$name$")]
	public void OnChange$name$(object $name$Entity, UpdateOperations updateAction)
	{ 
	 //Put your logic in here
	}
]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>