How to mock an inline table valued function in LINQ to SQL


/ Published in: C#
Save to your folder(s)

This example is for an inline table value function with one string parameter
t1 is of type YourDataContext and t2 is of type string(hence the name of the mole method)


Copy this code and paste it in your HTML
  1. MYourDataContext.AllInstances.YourInlineTableValuedFunctionString = (t1,t2) =>
  2. {
  3. var resultsList = new List<YourInlineTableValuedFunctionResult>
  4. {
  5. new YourInlineTableValuedFunctionResult(),
  6. new YourInlineTableValuedFunctionResult()
  7. };
  8. return resultsList.AsQueryable();
  9. }

URL: http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.aspx

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.