Skip to content

Commit ee58643

Browse files
author
zzzprojects
committed
add docs2
add docs2
1 parent 66bc436 commit ee58643

31 files changed

Lines changed: 2507 additions & 0 deletions

docs2/_data/meta.csv

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
permalink,title,meta-description,meta-keywords,h1,h2,nagivation,template
2+
index,Learn how to use Eval SQL.NET with Tutorials & Examples using C# syntax.,Learn how to use Eval SQL.NET with Tutorials & Examples using C# syntax.,,,,,full
3+
/404.html,Page Moved,Page Moved,,Page Moved,,,container-h1
4+
download,Download,Download,,Download,,no,full-h1
5+
pricing,Purchase,Purchase,,Purchase,,no,full-h1
6+
contact-us,Contact Us,Contact Us,,Contact Us,,no,full-h1
7+
tutorials,Tutorials,Tutorials,,Tutorials,,,container-h1
8+
overview,Overview,Overview,,Overview,,,
9+
requirements,Requirements,Requirements,,Requirements,,,
10+
installing,Installing,Installing,,Installing,,,
11+
upgrading,Upgrading,Upgrading,,Upgrading,,,
12+
licensing,Licensing,Licensing,,Licensing,,,
13+
arithmetic-expressions,Arithmetic Expressions,Arithmetic Expressions,,Arithmetic Expressions,,,
14+
split-text,Split Text,Split Text,,Split Text,,,
15+
regular-expressions,Reqular Expressions,Reqular Expressions,,Reqular Expressions,,,
16+
api,API,API,,API,,,
17+
eval,Eval,Eval,,Eval,,,
18+
value,Value,Value,,Value,,,
19+
options,Options,Options,,Options,,,
20+
configuration,Configuration,Configuration,,Configuration,,,
21+
articles,Articles,Articles,,Articles,,,
22+
faq,FAQ,FAQ,,FAQ,,,
23+
issue-tracker,Issue Tracker,Issue Tracker,,Issue Tracker,,,
24+
faq-general,FAQ - General,FAQ - General,,FAQ - General,,,
25+
faq-installation,FAQ - Installation,FAQ - Installation,,FAQ - Installation,,,
26+
faq-license,FAQ - License,FAQ - License,,FAQ - License,,,
27+
faq-eval-sql-net,FAQ - Eval SQL.NET,FAQ - Eval SQL.NET,,FAQ - Eval SQL.NET,,,
28+
problems,Problems,Problems,,Problems,,,
29+
sql-server-function,SQL Server Function (UDF),SQL Server Function (UDF),,SQL Server Function (UDF),,,
30+
sql-server-regex,SQL Server Regex,SQL Server Regex,,SQL Server Regex,,,
31+
sql-server-file-operation,SQL Server File Operation,SQL Server File Operation,,SQL Server File Operation,,,
32+
sql-server-eval,SQL Server Eval,SQL Server Eval,,SQL Server Eval,,,
33+
trial,Trial,Trial,,Trial,,,

docs2/pages/api/api.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
permalink: api
3+
---
4+
5+
## Overview
6+
7+
Let take a very short overview with the API
8+
9+
{% include template-example.html %}
10+
{% highlight csharp %}
11+
SELECT SQLNET::New('x+y').ValueInt('x', 1).ValueInt('y', 2).EvalInt() as Result
12+
{% endhighlight %}
13+
{% include component-try-it.html href='http://sqlfiddle.com/#!18/9eecb/1123' %}
14+
15+
16+
- **SQLNET:** A CLR Type created by Eval SQL.NET library
17+
- **"::":** This is how you call static method in SQL CLR
18+
- **New:** A static method which create a new instance of SQLNET Type
19+
- **ValueInt:** Set a int value for a specific parameter name used in the expression
20+
- **EvalInt:** Evaluate the expression and return a result of type INT
21+
22+
<div class="card-group">
23+
24+
<div class="card">
25+
<div class="card-header">
26+
<h2>Methods</h2>
27+
</div>
28+
29+
<div class="card-body">
30+
31+
<div markdown="1">
32+
33+
- [Eval](/eval)
34+
- [Value](/value)
35+
- [Options](/options)
36+
- [Configuration](/configuration)
37+
38+
</div>
39+
</div>
40+
</div>
41+
</div>
42+
43+
<style>
44+
.card-group .card-body {
45+
padding-top: 20px;
46+
}
47+
48+
.card-group .card-body li {
49+
padding-top: 5px;
50+
}
51+
</style>

docs2/pages/api/configuration.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
permalink: configuration
3+
---
4+
5+
## Configuration
6+
7+
Optional stored procedure for License and Configuration
8+
9+
10+
{% include template-example.html %}
11+
{% highlight csharp %}
12+
13+
CREATE PROCEDURE SQLNET_GlobalConfiguration
14+
AS
15+
BEGIN
16+
-- The procedure is automatically called when the server restart/assembly load
17+
-- If the assembly is already loaded, a manual execution is required
18+
-- EXEC SQLNET_Configuration
19+
DECLARE @isValid BIT = SQLNET::AddLicense('[LicenseName]', '[LicenseKey]')
20+
21+
-- SELECT 1
22+
SELECT @isValid
23+
24+
-- SELECT 1
25+
SELECT SQLNET::New('
26+
EvalManager.Configuration.RegisterAlias("MyMath", "Math");
27+
EvalManager.Configuration.ExpireCacheDelay = TimeSpan.FromMinutes(5);
28+
EvalManager.Configuration.SlidingExpirationDelegate = TimeSpan.FromHours(3);
29+
EvalManager.Configuration.SlidingExpirationItem = TimeSpan.FromMinutes(1);
30+
return true;
31+
').Eval()
32+
33+
END
34+
{% endhighlight %}
35+
36+
## Configuration Register & Unregister
37+
38+
Register or unregister information used by the EvalContext under which the code or expression is compiled.
39+
40+
- RegisterAlias(string alias, string name)
41+
- RegisterAssembly(param Assembly[])
42+
- RegisterDomainAssemblies()
43+
- RegisterExtensionMethod(param Type[])
44+
- RegisterExtensionMethod(param MethodInfo[])
45+
- RegisterGlobalConstant(string key, object value)
46+
- RegisterGlobalVariable(string key, object value)
47+
- RegisterStaticMember(param Type[])
48+
- RegisterStaticMember(param MemberInfo[])
49+
- RegisterType(param Type[])
50+
51+
[EvalContext - Register & Unregister](https://github.com/zzzprojects/Eval-Expression.NET/wiki/EvalContext-Register-&-Unregister)
52+
53+
## Configuration Options
54+
55+
Change option used by the EvalContext under which the code or expression is compiled.
56+
57+
- BindingFlags
58+
- UseCaretForExponent
59+
60+
[EvalContext - Options](https://github.com/zzzprojects/Eval-Expression.NET/wiki/EvalContext-Options)
61+
62+
## Configuration.ExpireCacheDelay
63+
64+
Sets a span of time within the next time the ExpireCache method is invoked to evict inactive cache item.
65+
66+
## Configuration.SlidingExpirationDelegate
67+
68+
Sets a span of time within which a delegate must be accessed before it evicted from the cache
69+
70+
## Configuration.SlidingExpirationItem
71+
72+
Sets a span of time within which an item must be accessed before it evicted from the cache
73+

docs2/pages/api/eval.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
---
2+
permalink: eval
3+
---
4+
## Eval
5+
6+
Evaluate the code or expression and return the result.
7+
8+
- Eval
9+
- EvalBigInt
10+
- EvalBinary
11+
- EvalBit
12+
- EvalDateTime
13+
- EvalInt
14+
- EvalSmallInt
15+
- EvalString
16+
- EvalTinyInt
17+
- EvalUniqueIdentifier
18+
- EvalVarBinary
19+
20+
{% include template-example.html %}
21+
{% highlight csharp %}
22+
DECLARE @sqlnet SQLNET = SQLNET::New('x+y').ValueInt('x', 1).ValueInt('y', 2).Root();
23+
24+
DECLARE @value_variant SQL_VARIANT = @sqlnet.Eval();
25+
DECLARE @value_int INT = @sqlnet.EvalInt();
26+
DECLARE @value_decimal DECIMAL(18, 2) = CAST(@sqlnet.Eval() AS DECIMAL(18, 2))
27+
28+
-- SELECT 3, 3, 3.00
29+
SELECT @value_variant as variant , @value_int as int, @value_decimal as decimal
30+
{% endhighlight %}
31+
{% include component-try-it.html href='http://sqlfiddle.com/#!18/58568/15' %}
32+
33+
## EvalReadAccess
34+
35+
Evaluate the code or expression allowing "Read" and return the result.
36+
37+
- EvalReadAccess
38+
- EvalReadAccessBigInt
39+
- EvalReadAccessBinary
40+
- EvalReadAccessBit
41+
- EvalReadAccessDateTime
42+
- EvalReadAccessInt
43+
- EvalReadAccessSmallInt
44+
- EvalReadAccessString
45+
- EvalReadAccessTinyInt
46+
- EvalReadAccessUniqueIdentifier
47+
- EvalReadAccessVarBinary
48+
49+
## EvalSQLNET
50+
51+
Evaluate the code or expression and return a new SQLNET object with the result in the parameter name "value"
52+
53+
{% include template-example.html %}
54+
{% highlight csharp %}
55+
-- Eval and create a new SQLNET object
56+
DECLARE @sqlnet SQLNET = SQLNET::New('var list = new List<int>() { 1, 2, 3, 4}')
57+
DECLARE @result SQLNET = @sqlnet.EvalSQLNET()
58+
59+
-- Use the value previously resolved
60+
-- SELECT 4
61+
SELECT @result.Code('value.Count').EvalInt() as Result
62+
Useful to optimize code with object initialization like Regex.
63+
{% endhighlight %}
64+
{% include component-try-it.html href='http://sqlfiddle.com/#!18/9eecb/989' %}
65+
66+
## EXEC SQLNET_EvalResultSet
67+
68+
Stored Procedures that evaluate code or expression and return a Result Set.
69+
70+
{% include template-example.html %}
71+
{% highlight csharp %}
72+
-- REQUIRE EXTERNAL_ACCESS permission
73+
DECLARE @sqlnet SQLNET = SQLNET::New('
74+
string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
75+
76+
var dir = new DirectoryInfo(path);
77+
return dir.GetFiles("*.*").Select(x => x.FullName).OrderBy(x => x).ToList();')
78+
.Impersonate()
79+
80+
-- SELECT * FROM DesktopFiles ORDER BY File.Fullname
81+
EXEC dbo.SQLNET_EvalResultSet @sqlnet
82+
You can output the result to the client or insert it in a table like a normal procedure.
83+
{% endhighlight %}
84+
85+
86+
## EvalTVF
87+
88+
Evaluate the code or expression from a Table-Valued Function (TVF).
89+
90+
- SQLNET_EvalTVF_1 (SQL_VARIANT)
91+
- SQLNET_EvalTVF_2 (SQL_VARIANT, SQL_VARIANT)
92+
- SQLNET_EvalTVF_3 (SQL_VARIANT, SQL_VARIANT, SQL_VARIANT)
93+
- SQLNET_EvalTVF_4 (SQL_VARIANT, SQL_VARIANT, SQL_VARIANT, SQL_VARIANT)
94+
- SQLNET_EvalTVF_5 (SQL_VARIANT, ..., SQL_VARIANT)
95+
- SQLNET_EvalTVF_String
96+
97+
{% include template-example.html %}
98+
{% highlight csharp %}
99+
CREATE FUNCTION [dbo].[fn_Split]
100+
(
101+
@input VARCHAR(MAX) ,
102+
@pattern VARCHAR(8000) = ','
103+
)
104+
RETURNS @split TABLE ( item VARCHAR(8000) )
105+
BEGIN
106+
DECLARE @regex_split SQLNET = SQLNET::New('Regex.Split(input, pattern)')
107+
.ValueString('input', @input)
108+
.ValueString('pattern', @pattern)
109+
110+
INSERT INTO @split
111+
SELECT CAST(Value_1 AS VARCHAR(8000))
112+
FROM [dbo].[SQLNET_EvalTVF_1](@regex_split)
113+
RETURN
114+
END
115+
116+
GO
117+
118+
-- SPLIT with multiple delimiters (',' and ';')
119+
SELECT * FROM dbo.fn_Split('1, 2, 3; 4; 5', ',|;')
120+
{% endhighlight %}
121+
{% include component-try-it.html href='http://sqlfiddle.com/#!18/b738f/2' %}

docs2/pages/api/options.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
permalink: options
3+
---
4+
5+
## AutoDispose()
6+
7+
AutoDispose object and delegate from the cache after the code has been evaluated.
8+
9+
{% include template-example.html %}
10+
{% highlight csharp %}
11+
-- SELECT 3
12+
SELECT SQLNET::New('1+2').AutoDispose().EvalInt() as Result
13+
14+
{% endhighlight %}
15+
{% include component-try-it.html href='http://sqlfiddle.com/#!18/9eecb/994' %}
16+
17+
Don't worry, we have you covered! Object and Delegate are automatically disposed after a period of time without activity.
18+
19+
## Code(string code)
20+
21+
Sets the code or expression to evaluate.
22+
23+
DECLARE @sqlnet SQLNET = SQLNET::New('')
24+
25+
{% include template-example.html %}
26+
{% highlight csharp %}
27+
DECLARE @sqlnet SQLNET = SQLNET::New('')
28+
29+
-- SELECT 3
30+
SELECT @sqlnet.Code('1+2').EvalInt() as Result
31+
32+
{% endhighlight %}
33+
{% include component-try-it.html href='http://sqlfiddle.com/#!18/9eecb/1125' %}
34+
35+
## Dispose()
36+
37+
Dispose object and delegate from the cache
38+
39+
{% include template-example.html %}
40+
{% highlight csharp %}
41+
DECLARE @sqlnet SQLNET = SQLNET::New('x + y')
42+
43+
SELECT @sqlnet
44+
.ValueInt('x', 1)
45+
.ValueInt('y', 2)
46+
.EvalInt() as Result
47+
48+
49+
SELECT @sqlnet.getcode() as Result
50+
51+
DECLARE @dispose BIT = @sqlnet.Dispose()
52+
53+
--Not work because dipose...
54+
SELECT @sqlnet
55+
.ValueInt('x', 1)
56+
.ValueInt('y', 2)
57+
.EvalInt() as Result
58+
59+
60+
--Not work because dipose...
61+
SELECT @sqlnet.getcode() as Result
62+
{% endhighlight %}
63+
{% include component-try-it.html href='http://sqlfiddle.com/#!18/9eecb/996' %}
64+
65+
Don't worry, we have you covered! Object and Delegate are automatically disposed after a period of time without activity.
66+
67+
## Impersonate()
68+
69+
Change the security context to impersonate the credential of the one who runs the T-SQL statements.
70+
71+
{% include template-example.html %}
72+
{% highlight csharp %}
73+
-- REQUIRE EXTERNAL_ACCESS permission
74+
DECLARE @sqlnet SQLNET = SQLNET::New('
75+
string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
76+
77+
var dir = new DirectoryInfo(path);
78+
return dir.GetFiles("*.*").Select(x => x.FullName).OrderBy(x => x).ToList();')
79+
.Impersonate()
80+
81+
-- SELECT * FROM DesktopFiles ORDER BY File.Fullname
82+
EXEC dbo.SQLNET_EvalResultSet @sqlnet
83+
84+
{% endhighlight %}
85+
86+
87+
Impersonate the current execution context under which the routine is executing.
88+
89+
## Root()
90+
91+
Root is required when the expression already specified value. This feature has been added to allow Parallelism.
92+
93+
{% include template-example.html %}
94+
{% highlight csharp %}
95+
DECLARE @sqlnet SQLNET = SQLNET::New('x+y').ValueInt('y', 2).Root()
96+
97+
-- SELECT 3
98+
SELECT @sqlnet.ValueInt('x', 1).EvalInt() as Result
99+
100+
{% endhighlight %}
101+
{% include component-try-it.html href='http://sqlfiddle.com/#!18/9eecb/997' %}

0 commit comments

Comments
 (0)