forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExtensionMethods.cs
38 lines (34 loc) · 1.25 KB
/
ExtensionMethods.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using NHibernate.Linq;
namespace NHibernate.Test.Linq
{
static class ExtensionMethods
{
[LinqExtensionMethod("Replace")]
public static string ReplaceExtension(this string subject, string search, string replaceWith)
{
throw new InvalidOperationException("To be translated to SQL only");
}
[LinqExtensionMethod]
public static string Replace(this string subject, string search, string replaceWith)
{
throw new InvalidOperationException("To be translated to SQL only");
}
// NH4 default behavior
[LinqExtensionMethod("Replace", LinqExtensionPreEvaluation.AllowPreEvaluation)]
public static string ReplaceWithEvaluation(this string subject, string search, string replaceWith)
{
if (subject == null)
throw new ArgumentNullException(nameof(subject));
return subject.Replace(search, replaceWith) + " (done in-memory)";
}
// Just for checking weird combination
[LinqExtensionMethod("Replace", LinqExtensionPreEvaluation.AllowPreEvaluation), NoPreEvaluation]
public static string ReplaceWithEvaluation2(this string subject, string search, string replaceWith)
{
if (subject == null)
throw new ArgumentNullException(nameof(subject));
return subject.Replace(search, replaceWith) + " (done in-memory)";
}
}
}