-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathAddProductColumnTypes.cs
54 lines (52 loc) · 2.06 KB
/
AddProductColumnTypes.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using System.Web;
using System.Collections.Specialized;
using Microsoft.Azure.Functions.Worker.Extensions.Sql;
using DotnetIsolatedTests.Common;
using System;
using System.Data.SqlTypes;
namespace DotnetIsolatedTests
{
public static class AddProductColumnTypes
{
/// <summary>
/// This function is used to test compatability with converting various data types to their respective
/// SQL server types.
/// </summary>
[Function(nameof(AddProductColumnTypes))]
[SqlOutput("dbo.ProductsColumnTypes", ConnectionStringSetting = "SqlConnectionString")]
public static ProductColumnTypes Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "addproduct-columntypes")] HttpRequestData req)
{
NameValueCollection queryStrings = HttpUtility.ParseQueryString(req.Url.Query);
var product = new ProductColumnTypes()
{
ProductId = int.Parse(queryStrings["productId"], null),
BigInt = int.MaxValue,
Bit = true,
DecimalType = 1.2345M,
Money = 1.23M,
Numeric = 1.2345M,
SmallInt = 0,
SmallMoney = 1.23M,
TinyInt = 1,
FloatType = 1.2,
Real = 1.2f,
Date = DateTime.UtcNow,
Datetime = new SqlDateTime(DateTime.UtcNow).Value,
Datetime2 = DateTime.UtcNow,
DatetimeOffset = DateTime.UtcNow,
SmallDatetime = new SqlDateTime(DateTime.UtcNow).Value,
Time = DateTime.UtcNow.TimeOfDay,
CharType = "test",
Varchar = "test",
Nchar = "\u2649",
Nvarchar = "\u2649",
};
return product;
}
}
}