Modernize tests, remove Tester project, and automate amalgamation pipeline
This commit is contained in:
@@ -1,63 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<PropertyGroup>
|
||||||
<PropertyGroup>
|
<OutputType>Exe</OutputType>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<ProductVersion>8.0.30703</ProductVersion>
|
<Nullable>enable</Nullable>
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<ProjectGuid>{A64D2052-D0CD-488E-BF05-E5952615D926}</ProjectGuid>
|
</PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<ItemGroup>
|
||||||
<RootNamespace>AmalgamationTool</RootNamespace>
|
<Compile Remove="DynamORM.Amalgamation.cs" />
|
||||||
<AssemblyName>AmalgamationTool</AssemblyName>
|
</ItemGroup>
|
||||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
</Project>
|
||||||
<TargetFrameworkProfile>
|
|
||||||
</TargetFrameworkProfile>
|
|
||||||
<FileAlignment>512</FileAlignment>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
|
||||||
<DebugSymbols>true</DebugSymbols>
|
|
||||||
<DebugType>full</DebugType>
|
|
||||||
<Optimize>false</Optimize>
|
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
|
||||||
<DebugType>pdbonly</DebugType>
|
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="System.Core" />
|
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="DynamORM.Amalgamation.cs">
|
|
||||||
<ExcludeFromStyleCop>True</ExcludeFromStyleCop>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Program.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
|
||||||
<Target Name="BeforeBuild">
|
|
||||||
</Target>
|
|
||||||
<Target Name="AfterBuild">
|
|
||||||
</Target>
|
|
||||||
-->
|
|
||||||
</Project>
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,192 +1,261 @@
|
|||||||
using System;
|
using System.Text;
|
||||||
using System.Collections.Generic;
|
using System.Text.RegularExpressions;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
namespace AmalgamationTool;
|
||||||
using System.Text;
|
|
||||||
using System.Text.RegularExpressions;
|
internal static class Program
|
||||||
|
{
|
||||||
namespace AmalgamationTool
|
private const string NamespaceToken = "namespace ";
|
||||||
{
|
|
||||||
internal class Program
|
private static int Main(string[] args)
|
||||||
{
|
{
|
||||||
private static void Main(string[] args)
|
if (args.Length < 2)
|
||||||
{
|
{
|
||||||
List<string> usings = new List<string>();
|
Console.Error.WriteLine("Usage: AmalgamationTool <sourceDir> <outputFile>");
|
||||||
Dictionary<string, List<string>> classes = new Dictionary<string, List<string>>();
|
return 1;
|
||||||
|
}
|
||||||
// Build a file using string builder.
|
|
||||||
StringBuilder sb = new StringBuilder();
|
var sourceDir = Path.GetFullPath(args[0].Trim('"', '\''));
|
||||||
|
var outputFile = Path.GetFullPath(args[1].Trim('"', '\''));
|
||||||
foreach (var f in new DirectoryInfo(Path.GetFullPath(args[0].Trim('"', '\''))).GetFiles("*.cs", SearchOption.AllDirectories))
|
|
||||||
{
|
if (!Directory.Exists(sourceDir))
|
||||||
string content = File.ReadAllText(f.FullName);
|
{
|
||||||
|
Console.Error.WriteLine($"Source directory not found: {sourceDir}");
|
||||||
string namespaceName = string.Empty;
|
return 2;
|
||||||
|
}
|
||||||
// Deal with usings
|
|
||||||
foreach (var u in content.Split(new string[] { Environment.NewLine }, StringSplitOptions.None)
|
var allUsings = new SortedSet<string>(StringComparer.Ordinal);
|
||||||
.Where(l => l.Trim().StartsWith("using ") && !l.Trim().StartsWith("using ("))
|
var namespaces = new SortedDictionary<string, List<string>>(StringComparer.Ordinal);
|
||||||
.Select(l => l.Trim()))
|
var headerComment = string.Empty;
|
||||||
if (!usings.Contains(u))
|
|
||||||
usings.Add(u);
|
foreach (var file in EnumerateInputFiles(sourceDir))
|
||||||
|
{
|
||||||
// Extract namespace
|
var content = File.ReadAllText(file);
|
||||||
|
if (string.IsNullOrWhiteSpace(content))
|
||||||
//if (args.Length > 2)
|
{
|
||||||
//{
|
continue;
|
||||||
// var tcontent = Regex.Replace(content, @"^\s*using\s+.*\s*;$", string.Empty);
|
}
|
||||||
// tcontent = Regex.Replace(content, @"^\s*namespace\s+.*\s*", string.Empty).Trim();
|
|
||||||
|
if (string.IsNullOrEmpty(headerComment))
|
||||||
// var ns = Regex.Match(content, @"^\s*namespace\s+(?<ns>.*)\s*");
|
{
|
||||||
|
headerComment = TryGetFileHeaderComment(content);
|
||||||
// if (ns.Success)
|
}
|
||||||
// {
|
|
||||||
// if (!classes.ContainsKey(ns.Groups["ns"].Value))
|
foreach (var @using in ExtractUsingLines(content))
|
||||||
// classes.Add(ns.Groups["ns"].Value, new List<string>());
|
{
|
||||||
|
allUsings.Add(@using);
|
||||||
// classes[ns.Groups["ns"].Value].Add(tcontent);
|
}
|
||||||
// }
|
|
||||||
//}
|
var nsData = TryExtractNamespaceBody(content);
|
||||||
//else
|
if (nsData == null)
|
||||||
{
|
{
|
||||||
if (content.Trim().Length == 0)
|
continue;
|
||||||
continue;
|
}
|
||||||
|
|
||||||
var nstart = content.IndexOf("namespace ") + "namespace ".Length;
|
if (!namespaces.TryGetValue(nsData.Value.Namespace, out var nodes))
|
||||||
var bbrace = content.IndexOf("{", nstart);
|
{
|
||||||
var nlen = bbrace - nstart;
|
nodes = new List<string>();
|
||||||
|
namespaces[nsData.Value.Namespace] = nodes;
|
||||||
if (nstart < "namespace ".Length)
|
}
|
||||||
{
|
|
||||||
if (f.Name.ToLower() == "assemblyinfo.cs")
|
nodes.Add(nsData.Value.Body);
|
||||||
{
|
}
|
||||||
var hs = content.IndexOf("/*");
|
|
||||||
var es = content.IndexOf("*/", hs) + 2;
|
var output = BuildAmalgamation(headerComment, allUsings, namespaces);
|
||||||
if (es > hs)
|
Directory.CreateDirectory(Path.GetDirectoryName(outputFile) ?? ".");
|
||||||
{
|
File.WriteAllText(outputFile, output, new UTF8Encoding(false));
|
||||||
sb.AppendLine(content.Substring(hs, es - hs));
|
|
||||||
sb.AppendLine();
|
Console.WriteLine($"Amalgamation generated: {outputFile}");
|
||||||
}
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
private static IEnumerable<string> EnumerateInputFiles(string sourceDir)
|
||||||
}
|
{
|
||||||
|
var root = new DirectoryInfo(sourceDir);
|
||||||
string ns = content.Substring(nstart, nlen).Trim();
|
return root.EnumerateFiles("*.cs", SearchOption.AllDirectories)
|
||||||
|
.Where(f => !f.FullName.Contains($"{Path.DirectorySeparatorChar}bin{Path.DirectorySeparatorChar}", StringComparison.OrdinalIgnoreCase))
|
||||||
// Add namespace if not exist
|
.Where(f => !f.FullName.Contains($"{Path.DirectorySeparatorChar}obj{Path.DirectorySeparatorChar}", StringComparison.OrdinalIgnoreCase))
|
||||||
if (!classes.ContainsKey(ns))
|
.Where(f => !f.Name.Equals("AssemblyInfo.cs", StringComparison.OrdinalIgnoreCase))
|
||||||
classes.Add(ns, new List<string>());
|
.Where(f => !f.Name.Equals("DynamORM.Amalgamation.cs", StringComparison.OrdinalIgnoreCase))
|
||||||
|
.Select(f => f.FullName)
|
||||||
var ebrace = content.LastIndexOf('}');
|
.OrderBy(f => f, StringComparer.Ordinal);
|
||||||
|
}
|
||||||
// Cut content as class/enum
|
|
||||||
classes[ns].Add(content.Substring(bbrace + 1, ebrace - bbrace - 1));
|
private static IEnumerable<string> ExtractUsingLines(string content)
|
||||||
}
|
{
|
||||||
}
|
var matches = Regex.Matches(content, @"^\s*using\s+[^;]+;", RegexOptions.Multiline);
|
||||||
|
foreach (Match match in matches)
|
||||||
usings.Sort();
|
{
|
||||||
|
var line = match.Value.Trim();
|
||||||
foreach (var u in usings)
|
if (!line.StartsWith("using (", StringComparison.Ordinal))
|
||||||
sb.AppendLine(u);
|
{
|
||||||
|
yield return line;
|
||||||
sb.AppendLine(@"
|
}
|
||||||
[module: System.Diagnostics.CodeAnalysis.SuppressMessage(""StyleCop.CSharp.MaintainabilityRules"", ""SA1402:FileMayOnlyContainASingleClass"", Justification = ""This is a generated file which generates all the necessary support classes."")]
|
}
|
||||||
[module: System.Diagnostics.CodeAnalysis.SuppressMessage(""StyleCop.CSharp.MaintainabilityRules"", ""SA1403:FileMayOnlyContainASingleNamespace"", Justification = ""This is a generated file which generates all the necessary support classes."")]");
|
}
|
||||||
|
|
||||||
FillClassesAndNamespacesIddented(classes, sb);
|
private static (string Namespace, string Body)? TryExtractNamespaceBody(string content)
|
||||||
|
{
|
||||||
string amalgamation = sb.ToString();
|
var nsIndex = content.IndexOf(NamespaceToken, StringComparison.Ordinal);
|
||||||
|
if (nsIndex < 0)
|
||||||
sb = new StringBuilder();
|
{
|
||||||
|
return null;
|
||||||
string prevTrimmed = null;
|
}
|
||||||
|
|
||||||
string[] array = amalgamation.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
|
var nsStart = nsIndex + NamespaceToken.Length;
|
||||||
|
var braceStart = content.IndexOf('{', nsStart);
|
||||||
for (int i = 0; i < array.Length; i++)
|
if (braceStart < 0)
|
||||||
{
|
{
|
||||||
string l = array[i];
|
return null;
|
||||||
var currentTrimmed = l.Trim();
|
}
|
||||||
var nextTrimmed = (i + 1 == array.Length) ? null : array[i + 1].Trim();
|
|
||||||
|
var namespaceName = content.Substring(nsStart, braceStart - nsStart).Trim();
|
||||||
if (prevTrimmed != null)
|
if (string.IsNullOrWhiteSpace(namespaceName))
|
||||||
{
|
{
|
||||||
switch (prevTrimmed)
|
return null;
|
||||||
{
|
}
|
||||||
case "":
|
|
||||||
if (currentTrimmed == string.Empty)
|
var braceEnd = FindMatchingBrace(content, braceStart);
|
||||||
continue;
|
if (braceEnd <= braceStart)
|
||||||
break;
|
{
|
||||||
|
return null;
|
||||||
case "{":
|
}
|
||||||
case "}":
|
|
||||||
if (currentTrimmed == string.Empty && (nextTrimmed == prevTrimmed || nextTrimmed == string.Empty))
|
var body = content.Substring(braceStart + 1, braceEnd - braceStart - 1).Trim('\r', '\n');
|
||||||
continue;
|
return (namespaceName, body);
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
}
|
private static int FindMatchingBrace(string content, int openBrace)
|
||||||
|
{
|
||||||
sb.AppendLine(l);
|
var depth = 0;
|
||||||
prevTrimmed = currentTrimmed;
|
for (var i = openBrace; i < content.Length; i++)
|
||||||
}
|
{
|
||||||
|
switch (content[i])
|
||||||
File.WriteAllText(Path.GetFullPath(args[1].Trim('"', '\'')), sb.ToString());
|
{
|
||||||
}
|
case '{':
|
||||||
|
depth++;
|
||||||
private static void FillClassesAndNamespaces(Dictionary<string, List<string>> classes, StringBuilder sb)
|
break;
|
||||||
{
|
case '}':
|
||||||
foreach (var n in classes)
|
depth--;
|
||||||
{
|
if (depth == 0)
|
||||||
sb.AppendFormat("namespace {0}{1}{{", n.Key, Environment.NewLine);
|
{
|
||||||
n.Value.ForEach(c => sb.Append(c));
|
return i;
|
||||||
sb.AppendLine("}");
|
}
|
||||||
sb.AppendLine(string.Empty);
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void FillClassesAndNamespacesIddented(Dictionary<string, List<string>> classes, StringBuilder sb)
|
return -1;
|
||||||
{
|
}
|
||||||
var min = classes.Min(k => k.Key.Split('.').Count());
|
|
||||||
|
private static string TryGetFileHeaderComment(string content)
|
||||||
foreach (var n in classes.Where(nc => nc.Key.Split('.').Count() == min))
|
{
|
||||||
{
|
var match = Regex.Match(content, @"^\s*/\*.*?\*/", RegexOptions.Singleline);
|
||||||
sb.AppendFormat("namespace {0}{1}{{", n.Key, Environment.NewLine);
|
return match.Success ? match.Value.Trim() : string.Empty;
|
||||||
n.Value.ForEach(c => sb.Append(c));
|
}
|
||||||
|
|
||||||
SubNamespaces(classes, n.Key, sb, min);
|
private static string BuildAmalgamation(
|
||||||
|
string headerComment,
|
||||||
sb.AppendLine("}");
|
IEnumerable<string> allUsings,
|
||||||
sb.AppendLine(string.Empty);
|
SortedDictionary<string, List<string>> namespaces)
|
||||||
}
|
{
|
||||||
}
|
var sb = new StringBuilder();
|
||||||
|
if (!string.IsNullOrWhiteSpace(headerComment))
|
||||||
private static void SubNamespaces(Dictionary<string, List<string>> classes, string p, StringBuilder sb, int ident)
|
{
|
||||||
{
|
sb.AppendLine(headerComment);
|
||||||
sb.AppendLine(string.Empty);
|
sb.AppendLine();
|
||||||
|
}
|
||||||
foreach (var n in classes.Where(nc => nc.Key.Split('.').Count() == ident + 1 && nc.Key.StartsWith(p)))
|
|
||||||
{
|
foreach (var @using in allUsings)
|
||||||
for (int i = 0; i < ident; i++) sb.Append(" ");
|
{
|
||||||
sb.AppendFormat("namespace {0}{1}", n.Key.Substring(p.Length + 1), Environment.NewLine);
|
sb.AppendLine(@using);
|
||||||
|
}
|
||||||
for (int i = 0; i < ident; i++) sb.Append(" ");
|
|
||||||
sb.Append("{");
|
sb.AppendLine();
|
||||||
n.Value.ForEach(c =>
|
sb.AppendLine("[module: System.Diagnostics.CodeAnalysis.SuppressMessage(\"StyleCop.CSharp.MaintainabilityRules\", \"SA1402:FileMayOnlyContainASingleClass\", Justification = \"This is a generated file which generates all the necessary support classes.\")]");
|
||||||
{
|
sb.AppendLine("[module: System.Diagnostics.CodeAnalysis.SuppressMessage(\"StyleCop.CSharp.MaintainabilityRules\", \"SA1403:FileMayOnlyContainASingleNamespace\", Justification = \"This is a generated file which generates all the necessary support classes.\")]");
|
||||||
foreach (var l in c.Split(new string[] { Environment.NewLine }, StringSplitOptions.None))
|
sb.AppendLine();
|
||||||
{
|
|
||||||
for (int i = 0; i < ident; i++) sb.Append(" ");
|
FillNamespaceTree(namespaces, sb);
|
||||||
sb.AppendLine(l);
|
return CleanupWhitespace(sb.ToString());
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
private static void FillNamespaceTree(SortedDictionary<string, List<string>> classes, StringBuilder sb)
|
||||||
SubNamespaces(classes, n.Key, sb, ident + 1);
|
{
|
||||||
|
var minDepth = classes.Keys.Min(k => k.Split('.').Length);
|
||||||
for (int i = 0; i < ident; i++) sb.Append(" ");
|
|
||||||
sb.AppendLine("}");
|
foreach (var root in classes.Where(c => c.Key.Split('.').Length == minDepth))
|
||||||
sb.AppendLine(string.Empty);
|
{
|
||||||
}
|
sb.AppendLine($"namespace {root.Key}");
|
||||||
}
|
sb.AppendLine("{");
|
||||||
}
|
|
||||||
}
|
foreach (var code in root.Value)
|
||||||
|
{
|
||||||
|
sb.AppendLine(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
FillSubNamespaces(classes, root.Key, minDepth, sb);
|
||||||
|
sb.AppendLine("}");
|
||||||
|
sb.AppendLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void FillSubNamespaces(
|
||||||
|
SortedDictionary<string, List<string>> classes,
|
||||||
|
string parent,
|
||||||
|
int depth,
|
||||||
|
StringBuilder sb)
|
||||||
|
{
|
||||||
|
foreach (var child in classes.Where(c => c.Key.StartsWith(parent + ".", StringComparison.Ordinal) && c.Key.Split('.').Length == depth + 1))
|
||||||
|
{
|
||||||
|
var indent = new string(' ', depth * 4);
|
||||||
|
var shortNamespace = child.Key.Substring(parent.Length + 1);
|
||||||
|
sb.Append(indent).AppendLine($"namespace {shortNamespace}");
|
||||||
|
sb.Append(indent).AppendLine("{");
|
||||||
|
|
||||||
|
foreach (var block in child.Value)
|
||||||
|
{
|
||||||
|
foreach (var line in block.Replace("\r\n", "\n").Split('\n'))
|
||||||
|
{
|
||||||
|
sb.Append(indent).Append(" ").AppendLine(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FillSubNamespaces(classes, child.Key, depth + 1, sb);
|
||||||
|
sb.Append(indent).AppendLine("}");
|
||||||
|
sb.AppendLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string CleanupWhitespace(string content)
|
||||||
|
{
|
||||||
|
var lines = content.Replace("\r\n", "\n").Split('\n');
|
||||||
|
var output = new StringBuilder();
|
||||||
|
string? previous = null;
|
||||||
|
|
||||||
|
for (var i = 0; i < lines.Length; i++)
|
||||||
|
{
|
||||||
|
var current = lines[i];
|
||||||
|
var trimmed = current.Trim();
|
||||||
|
var nextTrimmed = i + 1 < lines.Length ? lines[i + 1].Trim() : null;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(trimmed))
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(previous))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (previous == "{" || previous == "}" || nextTrimmed == "}" || string.IsNullOrEmpty(nextTrimmed))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
output.AppendLine(current.TrimEnd());
|
||||||
|
previous = trimmed;
|
||||||
|
}
|
||||||
|
|
||||||
|
return output.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
|
||||||
// set of attributes. Change these attribute values to modify the information
|
|
||||||
// associated with an assembly.
|
|
||||||
[assembly: AssemblyTitle("AmalgamationTool")]
|
|
||||||
[assembly: AssemblyDescription("")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("Microsoft")]
|
|
||||||
[assembly: AssemblyProduct("AmalgamationTool")]
|
|
||||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2014")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
|
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
|
||||||
// to COM components. If you need to access a type in this assembly from
|
|
||||||
// COM, set the ComVisible attribute to true on that type.
|
|
||||||
[assembly: ComVisible(false)]
|
|
||||||
|
|
||||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|
||||||
[assembly: Guid("de540809-dd27-47b1-bb01-7dce3a880cde")]
|
|
||||||
|
|
||||||
// Version information for an assembly consists of the following four values:
|
|
||||||
//
|
|
||||||
// Major Version
|
|
||||||
// Minor Version
|
|
||||||
// Build Number
|
|
||||||
// Revision
|
|
||||||
//
|
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
|
||||||
// by using the '*' as shown below:
|
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
|
||||||
[assembly: AssemblyVersion("1.0.0.0")]
|
|
||||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
||||||
@@ -25,13 +25,13 @@
|
|||||||
<ProjectReference Include="..\DynamORM\DynamORM.csproj" />
|
<ProjectReference Include="..\DynamORM\DynamORM.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
|
<PackageReference Include="coverlet.collector" Version="6.0.4"/>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0"/>
|
||||||
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1"/>
|
<PackageReference Include="NUnit" Version="3.14.0"/>
|
||||||
<PackageReference Include="MSTest.TestFramework" Version="3.1.1"/>
|
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0"/>
|
||||||
<PackageReference Include="System.Data.SQLite" Version="1.0.119" />
|
<PackageReference Include="System.Data.SQLite" Version="1.0.119" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Remove="Helpers\**" />
|
<EmbeddedResource Remove="Helpers\**" />
|
||||||
|
|||||||
@@ -1,64 +1,64 @@
|
|||||||
/*
|
/*
|
||||||
* DynamORM - Dynamic Object-Relational Mapping library.
|
* DynamORM - Dynamic Object-Relational Mapping library.
|
||||||
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using NUnit.Framework;
|
||||||
|
|
||||||
namespace DynamORM.Tests.Helpers
|
namespace DynamORM.Tests.Helpers
|
||||||
{
|
{
|
||||||
/// <summary>Class responsible for users operations testing.</summary>
|
/// <summary>Class responsible for users operations testing.</summary>
|
||||||
[TestClass]
|
[TestFixture]
|
||||||
public class AttachToDebugger
|
public class AttachToDebugger
|
||||||
{
|
{
|
||||||
/// <summary>Test anonymous type compatibility.</summary>
|
/// <summary>Test anonymous type compatibility.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestAnonType()
|
public void TestAnonType()
|
||||||
{
|
{
|
||||||
var a = new { x = 1, y = 2 };
|
var a = new { x = 1, y = 2 };
|
||||||
var b = new { x = 3, y = 4 };
|
var b = new { x = 3, y = 4 };
|
||||||
|
|
||||||
Assert.AreEqual(a.GetType(), b.GetType());
|
Assert.AreEqual(a.GetType(), b.GetType());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test anonymous type value.</summary>
|
/// <summary>Test anonymous type value.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestAnonTypeValue()
|
public void TestAnonTypeValue()
|
||||||
{
|
{
|
||||||
var a = new { x = 1, y = "bla bla" };
|
var a = new { x = 1, y = "bla bla" };
|
||||||
var b = new { x = 1, y = "bla bla" };
|
var b = new { x = 1, y = "bla bla" };
|
||||||
|
|
||||||
Assert.AreEqual(a, b);
|
Assert.AreEqual(a, b);
|
||||||
Assert.IsTrue(a.Equals(b));
|
Assert.IsTrue(a.Equals(b));
|
||||||
|
|
||||||
Dictionary<object, int> dict = new Dictionary<object, int>() { { a, 999 } };
|
Dictionary<object, int> dict = new Dictionary<object, int>() { { a, 999 } };
|
||||||
|
|
||||||
Assert.IsTrue(dict.ContainsKey(b));
|
Assert.IsTrue(dict.ContainsKey(b));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,121 +1,121 @@
|
|||||||
/*
|
/*
|
||||||
* DynamORM - Dynamic Object-Relational Mapping library.
|
* DynamORM - Dynamic Object-Relational Mapping library.
|
||||||
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using DynamORM.Helpers.Dynamics;
|
using DynamORM.Helpers.Dynamics;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using NUnit.Framework;
|
||||||
|
|
||||||
namespace DynamORM.Tests.Helpers.Dynamic
|
namespace DynamORM.Tests.Helpers.Dynamic
|
||||||
{
|
{
|
||||||
/// <summary><see cref="DynamicParser"/> tests.</summary>
|
/// <summary><see cref="DynamicParser"/> tests.</summary>
|
||||||
[TestClass]
|
[TestFixture]
|
||||||
public class DynamicParserTests
|
public class DynamicParserTests
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the get member.
|
/// Tests the get member.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestGetMember()
|
public void TestGetMember()
|
||||||
{
|
{
|
||||||
Func<dynamic, object> f = x => x.SomePropery;
|
Func<dynamic, object> f = x => x.SomePropery;
|
||||||
|
|
||||||
var val = DynamicParser.Parse(f).Result as DynamicParser.Node.GetMember;
|
var val = DynamicParser.Parse(f).Result as DynamicParser.Node.GetMember;
|
||||||
|
|
||||||
Assert.IsNotNull(val);
|
Assert.IsNotNull(val);
|
||||||
Assert.AreEqual("SomePropery", val.Name);
|
Assert.AreEqual("SomePropery", val.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the set member.
|
/// Tests the set member.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestSetMember()
|
public void TestSetMember()
|
||||||
{
|
{
|
||||||
Func<dynamic, object> f = x => x.SomePropery = "value";
|
Func<dynamic, object> f = x => x.SomePropery = "value";
|
||||||
|
|
||||||
var val = DynamicParser.Parse(f).Result as DynamicParser.Node.SetMember;
|
var val = DynamicParser.Parse(f).Result as DynamicParser.Node.SetMember;
|
||||||
|
|
||||||
Assert.IsNotNull(val);
|
Assert.IsNotNull(val);
|
||||||
Assert.AreEqual("SomePropery", val.Name);
|
Assert.AreEqual("SomePropery", val.Name);
|
||||||
Assert.AreEqual("value", val.Value);
|
Assert.AreEqual("value", val.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the index of the get.
|
/// Tests the index of the get.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestGetIndex()
|
public void TestGetIndex()
|
||||||
{
|
{
|
||||||
Func<dynamic, object> f = x => x.SomePropery[0];
|
Func<dynamic, object> f = x => x.SomePropery[0];
|
||||||
|
|
||||||
var val = DynamicParser.Parse(f).Result as DynamicParser.Node.GetIndex;
|
var val = DynamicParser.Parse(f).Result as DynamicParser.Node.GetIndex;
|
||||||
|
|
||||||
Assert.IsNotNull(val);
|
Assert.IsNotNull(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the index of the set.
|
/// Tests the index of the set.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestSetIndex()
|
public void TestSetIndex()
|
||||||
{
|
{
|
||||||
Func<dynamic, object> f = x => x.SomePropery[0] = "value";
|
Func<dynamic, object> f = x => x.SomePropery[0] = "value";
|
||||||
|
|
||||||
var val = DynamicParser.Parse(f).Result as DynamicParser.Node.SetIndex;
|
var val = DynamicParser.Parse(f).Result as DynamicParser.Node.SetIndex;
|
||||||
|
|
||||||
Assert.IsNotNull(val);
|
Assert.IsNotNull(val);
|
||||||
Assert.AreEqual("value", val.Value);
|
Assert.AreEqual("value", val.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests something.
|
/// Tests something.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestSomething()
|
public void TestSomething()
|
||||||
{
|
{
|
||||||
Func<dynamic, object> f = x => x.SomePropery == "value" || x.OtherProperty == -1;
|
Func<dynamic, object> f = x => x.SomePropery == "value" || x.OtherProperty == -1;
|
||||||
|
|
||||||
var p = DynamicParser.Parse(f);
|
var p = DynamicParser.Parse(f);
|
||||||
var val = p.Result as DynamicParser.Node.Binary;
|
var val = p.Result as DynamicParser.Node.Binary;
|
||||||
|
|
||||||
Assert.IsNotNull(val);
|
Assert.IsNotNull(val);
|
||||||
|
|
||||||
var left = val.Host as DynamicParser.Node.Binary;
|
var left = val.Host as DynamicParser.Node.Binary;
|
||||||
var right = val.Right as DynamicParser.Node.Binary;
|
var right = val.Right as DynamicParser.Node.Binary;
|
||||||
|
|
||||||
Assert.IsNotNull(left);
|
Assert.IsNotNull(left);
|
||||||
Assert.IsNotNull(right);
|
Assert.IsNotNull(right);
|
||||||
|
|
||||||
Assert.IsInstanceOfType(left.Host, typeof(DynamicParser.Node.GetMember));
|
Assert.IsInstanceOf<DynamicParser.Node.GetMember>(left.Host);
|
||||||
Assert.IsInstanceOfType(right.Host, typeof(DynamicParser.Node.GetMember));
|
Assert.IsInstanceOf<DynamicParser.Node.GetMember>(right.Host);
|
||||||
|
|
||||||
Assert.AreEqual("value", left.Right);
|
Assert.AreEqual("value", left.Right);
|
||||||
Assert.AreEqual(-1, right.Right);
|
Assert.AreEqual(-1, right.Right);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,100 +1,100 @@
|
|||||||
/*
|
/*
|
||||||
* DynamORM - Dynamic Object-Relational Mapping library.
|
* DynamORM - Dynamic Object-Relational Mapping library.
|
||||||
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using NUnit.Framework;
|
||||||
|
|
||||||
namespace DynamORM.Tests.Helpers
|
namespace DynamORM.Tests.Helpers
|
||||||
{
|
{
|
||||||
/// <summary>Pooling tests.</summary>
|
/// <summary>Pooling tests.</summary>
|
||||||
[TestClass]
|
[TestFixture]
|
||||||
public class PoolingTests : TestsBase
|
public class PoolingTests : TestsBase
|
||||||
{
|
{
|
||||||
/// <summary>Setup test parameters.</summary>
|
/// <summary>Setup test parameters.</summary>
|
||||||
[TestInitialize]
|
[SetUp]
|
||||||
public virtual void SetUp()
|
public virtual void SetUp()
|
||||||
{
|
{
|
||||||
CreateTestDatabase();
|
CreateTestDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Tear down test objects.</summary>
|
/// <summary>Tear down test objects.</summary>
|
||||||
[TestCleanup]
|
[TearDown]
|
||||||
public virtual void TearDown()
|
public virtual void TearDown()
|
||||||
{
|
{
|
||||||
DestroyDynamicDatabase();
|
DestroyDynamicDatabase();
|
||||||
DestroyTestDatabase();
|
DestroyTestDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test single mode command disposing.</summary>
|
/// <summary>Test single mode command disposing.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestSingleModeCommand()
|
public void TestSingleModeCommand()
|
||||||
{
|
{
|
||||||
CreateDynamicDatabase();
|
CreateDynamicDatabase();
|
||||||
|
|
||||||
var cmd = Database.Open().CreateCommand();
|
var cmd = Database.Open().CreateCommand();
|
||||||
|
|
||||||
cmd.SetCommand("SELECT COUNT(0) FROM sqlite_master;");
|
cmd.SetCommand("SELECT COUNT(0) FROM sqlite_master;");
|
||||||
|
|
||||||
Database.Dispose();
|
Database.Dispose();
|
||||||
Database = null;
|
Database = null;
|
||||||
|
|
||||||
Assert.ThrowsException<DynamicQueryException>(() => cmd.ExecuteScalar());
|
Assert.Throws<DynamicQueryException>(() => cmd.ExecuteScalar());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test single mode transaction disposing.</summary>
|
/// <summary>Test single mode transaction disposing.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestSingleModeTransaction()
|
public void TestSingleModeTransaction()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CreateDynamicDatabase();
|
CreateDynamicDatabase();
|
||||||
|
|
||||||
using (var conn = Database.Open())
|
using (var conn = Database.Open())
|
||||||
using (var trans = conn.BeginTransaction())
|
using (var trans = conn.BeginTransaction())
|
||||||
using (var cmd = conn.CreateCommand())
|
using (var cmd = conn.CreateCommand())
|
||||||
{
|
{
|
||||||
Assert.AreEqual(1, cmd.SetCommand("INSERT INTO \"users\" (\"code\") VALUES ('999');").ExecuteNonQuery());
|
Assert.AreEqual(1, cmd.SetCommand("INSERT INTO \"users\" (\"code\") VALUES ('999');").ExecuteNonQuery());
|
||||||
|
|
||||||
Database.Dispose();
|
Database.Dispose();
|
||||||
Database = null;
|
Database = null;
|
||||||
|
|
||||||
trans.Commit();
|
trans.Commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify (rollback)
|
// Verify (rollback)
|
||||||
CreateDynamicDatabase();
|
CreateDynamicDatabase();
|
||||||
Assert.AreEqual(0, Database.Table("users").Count(columns: "id", code: "999"));
|
Assert.AreEqual(0, Database.Table("users").Count(columns: "id", code: "999"));
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
// Remove for next tests
|
// Remove for next tests
|
||||||
Database.Dispose();
|
Database.Dispose();
|
||||||
Database = null;
|
Database = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,80 +1,80 @@
|
|||||||
/*
|
/*
|
||||||
* DynamORM - Dynamic Object-Relational Mapping library.
|
* DynamORM - Dynamic Object-Relational Mapping library.
|
||||||
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using DynamORM.Mapper;
|
using DynamORM.Mapper;
|
||||||
using DynamORM.Validation;
|
using DynamORM.Validation;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using NUnit.Framework;
|
||||||
|
|
||||||
namespace DynamORM.Tests.Helpers.Validation
|
namespace DynamORM.Tests.Helpers.Validation
|
||||||
{
|
{
|
||||||
[TestClass]
|
[TestFixture]
|
||||||
public class ObjectValidationTest
|
public class ObjectValidationTest
|
||||||
{
|
{
|
||||||
public class TestObject
|
public class TestObject
|
||||||
{
|
{
|
||||||
[Required(1f, 10f)]
|
[Required(1f, 10f)]
|
||||||
public int TestInt { get; set; }
|
public int TestInt { get; set; }
|
||||||
|
|
||||||
[Required(7, false, false)]
|
[Required(7, false, false)]
|
||||||
public string CanBeNull { get; set; }
|
public string CanBeNull { get; set; }
|
||||||
|
|
||||||
[Required(2, true)]
|
[Required(2, true)]
|
||||||
[Required(7, 18, ElementRequirement = true)]
|
[Required(7, 18, ElementRequirement = true)]
|
||||||
public decimal[] ArrayTest { get; set; }
|
public decimal[] ArrayTest { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void ValidateCorrectObject()
|
public void ValidateCorrectObject()
|
||||||
{
|
{
|
||||||
var result = DynamicMapperCache.GetMapper<TestObject>().ValidateObject(
|
var result = DynamicMapperCache.GetMapper<TestObject>().ValidateObject(
|
||||||
new TestObject
|
new TestObject
|
||||||
{
|
{
|
||||||
TestInt = 2,
|
TestInt = 2,
|
||||||
ArrayTest = new decimal[] { 7, 18 },
|
ArrayTest = new decimal[] { 7, 18 },
|
||||||
});
|
});
|
||||||
|
|
||||||
Assert.IsNotNull(result);
|
Assert.IsNotNull(result);
|
||||||
Assert.AreEqual(0, result.Count);
|
Assert.AreEqual(0, result.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void ValidateIncorrectObject()
|
public void ValidateIncorrectObject()
|
||||||
{
|
{
|
||||||
var result = DynamicMapperCache.GetMapper<TestObject>().ValidateObject(
|
var result = DynamicMapperCache.GetMapper<TestObject>().ValidateObject(
|
||||||
new TestObject
|
new TestObject
|
||||||
{
|
{
|
||||||
TestInt = 0,
|
TestInt = 0,
|
||||||
CanBeNull = string.Empty,
|
CanBeNull = string.Empty,
|
||||||
ArrayTest = new decimal[] { 0, 0 },
|
ArrayTest = new decimal[] { 0, 0 },
|
||||||
});
|
});
|
||||||
|
|
||||||
Assert.IsNotNull(result);
|
Assert.IsNotNull(result);
|
||||||
Assert.AreEqual(4, result.Count);
|
Assert.AreEqual(4, result.Count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,391 +1,391 @@
|
|||||||
/*
|
/*
|
||||||
* DynamORM - Dynamic Object-Relational Mapping library.
|
* DynamORM - Dynamic Object-Relational Mapping library.
|
||||||
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using DynamORM.Tests.Helpers;
|
using DynamORM.Tests.Helpers;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using NUnit.Framework;
|
||||||
|
|
||||||
namespace DynamORM.Tests.Modify
|
namespace DynamORM.Tests.Modify
|
||||||
{
|
{
|
||||||
/// <summary>Test standard dynamic access ORM.</summary>
|
/// <summary>Test standard dynamic access ORM.</summary>
|
||||||
[TestClass]
|
[TestFixture]
|
||||||
public class DynamicModificationTests : TestsBase
|
public class DynamicModificationTests : TestsBase
|
||||||
{
|
{
|
||||||
/// <summary>Setup test parameters.</summary>
|
/// <summary>Setup test parameters.</summary>
|
||||||
[TestInitialize]
|
[SetUp]
|
||||||
public virtual void SetUp()
|
public virtual void SetUp()
|
||||||
{
|
{
|
||||||
CreateTestDatabase();
|
CreateTestDatabase();
|
||||||
CreateDynamicDatabase();
|
CreateDynamicDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Tear down test objects.</summary>
|
/// <summary>Tear down test objects.</summary>
|
||||||
[TestCleanup]
|
[TearDown]
|
||||||
public virtual void TearDown()
|
public virtual void TearDown()
|
||||||
{
|
{
|
||||||
DestroyDynamicDatabase();
|
DestroyDynamicDatabase();
|
||||||
DestroyTestDatabase();
|
DestroyTestDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Create table using specified method.</summary>
|
/// <summary>Create table using specified method.</summary>
|
||||||
/// <returns>Dynamic table.</returns>
|
/// <returns>Dynamic table.</returns>
|
||||||
public virtual dynamic GetTestTable()
|
public virtual dynamic GetTestTable()
|
||||||
{
|
{
|
||||||
return Database.Table("users");
|
return Database.Table("users");
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Insert
|
#region Insert
|
||||||
|
|
||||||
/// <summary>Test row insertion by dynamic arguments.</summary>
|
/// <summary>Test row insertion by dynamic arguments.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestInsertByArguments()
|
public void TestInsertByArguments()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(1, GetTestTable().Insert(code: "201", first: null, last: "Gagarin", email: "juri.gagarin@megacorp.com", quote: "bla, bla, bla"));
|
Assert.AreEqual(1, GetTestTable().Insert(code: "201", first: null, last: "Gagarin", email: "juri.gagarin@megacorp.com", quote: "bla, bla, bla"));
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
var o = GetTestTable().Single(code: "201");
|
var o = GetTestTable().Single(code: "201");
|
||||||
Assert.AreNotEqual(200, o.id);
|
Assert.AreNotEqual(200, o.id);
|
||||||
Assert.AreEqual("201", o.code.ToString());
|
Assert.AreEqual("201", o.code.ToString());
|
||||||
Assert.IsNull(o.first);
|
Assert.IsNull(o.first);
|
||||||
Assert.AreEqual("Gagarin", o.last);
|
Assert.AreEqual("Gagarin", o.last);
|
||||||
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
|
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
|
||||||
Assert.AreEqual("bla, bla, bla", o.quote);
|
Assert.AreEqual("bla, bla, bla", o.quote);
|
||||||
Assert.IsNull(o.password);
|
Assert.IsNull(o.password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test row insertion by dynamic object.</summary>
|
/// <summary>Test row insertion by dynamic object.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestInsertByDynamicObjects()
|
public void TestInsertByDynamicObjects()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(1, GetTestTable().Insert(values: new { code = "202", first = DBNull.Value, last = "Gagarin", email = "juri.gagarin@megacorp.com", quote = "bla, bla, bla" }));
|
Assert.AreEqual(1, GetTestTable().Insert(values: new { code = "202", first = DBNull.Value, last = "Gagarin", email = "juri.gagarin@megacorp.com", quote = "bla, bla, bla" }));
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
var o = GetTestTable().Single(code: "202");
|
var o = GetTestTable().Single(code: "202");
|
||||||
Assert.AreNotEqual(200, o.id);
|
Assert.AreNotEqual(200, o.id);
|
||||||
Assert.AreEqual("202", o.code.ToString());
|
Assert.AreEqual("202", o.code.ToString());
|
||||||
Assert.IsNull(o.first);
|
Assert.IsNull(o.first);
|
||||||
Assert.AreEqual("Gagarin", o.last);
|
Assert.AreEqual("Gagarin", o.last);
|
||||||
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
|
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
|
||||||
Assert.AreEqual("bla, bla, bla", o.quote);
|
Assert.AreEqual("bla, bla, bla", o.quote);
|
||||||
Assert.IsNull(o.password);
|
Assert.IsNull(o.password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test row insertion by mapped object.</summary>
|
/// <summary>Test row insertion by mapped object.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestInsertByMappedObject()
|
public void TestInsertByMappedObject()
|
||||||
{
|
{
|
||||||
var u = GetTestTable();
|
var u = GetTestTable();
|
||||||
|
|
||||||
Assert.AreEqual(1, u.Insert(values: new Users
|
Assert.AreEqual(1, u.Insert(values: new Users
|
||||||
{
|
{
|
||||||
Id = u.Max(columns: "id") + 1,
|
Id = u.Max(columns: "id") + 1,
|
||||||
Code = "203",
|
Code = "203",
|
||||||
First = null,
|
First = null,
|
||||||
Last = "Gagarin",
|
Last = "Gagarin",
|
||||||
Email = "juri.gagarin@megacorp.com",
|
Email = "juri.gagarin@megacorp.com",
|
||||||
Quote = "bla, bla, bla"
|
Quote = "bla, bla, bla"
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
var o = u.Single(code: "203");
|
var o = u.Single(code: "203");
|
||||||
Assert.AreNotEqual(200, o.id);
|
Assert.AreNotEqual(200, o.id);
|
||||||
Assert.AreEqual("203", o.code.ToString());
|
Assert.AreEqual("203", o.code.ToString());
|
||||||
Assert.IsNull(o.first);
|
Assert.IsNull(o.first);
|
||||||
Assert.AreEqual("Gagarin", o.last);
|
Assert.AreEqual("Gagarin", o.last);
|
||||||
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
|
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
|
||||||
Assert.AreEqual("bla, bla, bla", o.quote);
|
Assert.AreEqual("bla, bla, bla", o.quote);
|
||||||
Assert.IsNull(o.password);
|
Assert.IsNull(o.password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test row insertion by basic object.</summary>
|
/// <summary>Test row insertion by basic object.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestInsertByBasicObject()
|
public void TestInsertByBasicObject()
|
||||||
{
|
{
|
||||||
var u = GetTestTable();
|
var u = GetTestTable();
|
||||||
|
|
||||||
Assert.AreEqual(1, u.Insert(values: new users
|
Assert.AreEqual(1, u.Insert(values: new users
|
||||||
{
|
{
|
||||||
id = u.Max(columns: "id") + 1,
|
id = u.Max(columns: "id") + 1,
|
||||||
code = "204",
|
code = "204",
|
||||||
first = null,
|
first = null,
|
||||||
last = "Gagarin",
|
last = "Gagarin",
|
||||||
email = "juri.gagarin@megacorp.com",
|
email = "juri.gagarin@megacorp.com",
|
||||||
quote = "bla, bla, bla"
|
quote = "bla, bla, bla"
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
var o = u.Single(code: "204");
|
var o = u.Single(code: "204");
|
||||||
Assert.AreNotEqual(200, o.id);
|
Assert.AreNotEqual(200, o.id);
|
||||||
Assert.AreEqual("204", o.code.ToString());
|
Assert.AreEqual("204", o.code.ToString());
|
||||||
Assert.IsNull(o.first);
|
Assert.IsNull(o.first);
|
||||||
Assert.AreEqual("Gagarin", o.last);
|
Assert.AreEqual("Gagarin", o.last);
|
||||||
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
|
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
|
||||||
Assert.AreEqual("bla, bla, bla", o.quote);
|
Assert.AreEqual("bla, bla, bla", o.quote);
|
||||||
Assert.IsNull(o.password);
|
Assert.IsNull(o.password);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Insert
|
#endregion Insert
|
||||||
|
|
||||||
#region Update
|
#region Update
|
||||||
|
|
||||||
/// <summary>Test row updating by dynamic arguments.</summary>
|
/// <summary>Test row updating by dynamic arguments.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestUpdateByArguments()
|
public void TestUpdateByArguments()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(1, GetTestTable().Update(id: 1, code: "201", first: null, last: "Gagarin", email: "juri.gagarin@megacorp.com", quote: "bla, bla, bla"));
|
Assert.AreEqual(1, GetTestTable().Update(id: 1, code: "201", first: null, last: "Gagarin", email: "juri.gagarin@megacorp.com", quote: "bla, bla, bla"));
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
var o = GetTestTable().Single(code: "201");
|
var o = GetTestTable().Single(code: "201");
|
||||||
Assert.AreEqual(1, o.id);
|
Assert.AreEqual(1, o.id);
|
||||||
Assert.AreEqual("201", o.code.ToString());
|
Assert.AreEqual("201", o.code.ToString());
|
||||||
Assert.IsNull(o.first);
|
Assert.IsNull(o.first);
|
||||||
Assert.AreEqual("Gagarin", o.last);
|
Assert.AreEqual("Gagarin", o.last);
|
||||||
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
|
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
|
||||||
Assert.AreEqual("bla, bla, bla", o.quote);
|
Assert.AreEqual("bla, bla, bla", o.quote);
|
||||||
Assert.IsNull(o.password);
|
Assert.IsNull(o.password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test row updating by dynamic objects.</summary>
|
/// <summary>Test row updating by dynamic objects.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestUpdateByDynamicObject()
|
public void TestUpdateByDynamicObject()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(1, GetTestTable().Update(update: new { id = 2, code = "202", first = DBNull.Value, last = "Gagarin", email = "juri.gagarin@megacorp.com", quote = "bla, bla, bla" }));
|
Assert.AreEqual(1, GetTestTable().Update(update: new { id = 2, code = "202", first = DBNull.Value, last = "Gagarin", email = "juri.gagarin@megacorp.com", quote = "bla, bla, bla" }));
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
var o = GetTestTable().Single(code: "202");
|
var o = GetTestTable().Single(code: "202");
|
||||||
Assert.AreEqual(2, o.id);
|
Assert.AreEqual(2, o.id);
|
||||||
Assert.AreEqual("202", o.code.ToString());
|
Assert.AreEqual("202", o.code.ToString());
|
||||||
Assert.IsNull(o.first);
|
Assert.IsNull(o.first);
|
||||||
Assert.AreEqual("Gagarin", o.last);
|
Assert.AreEqual("Gagarin", o.last);
|
||||||
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
|
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
|
||||||
Assert.AreEqual("bla, bla, bla", o.quote);
|
Assert.AreEqual("bla, bla, bla", o.quote);
|
||||||
Assert.IsNull(o.password);
|
Assert.IsNull(o.password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test row updating by mapped object.</summary>
|
/// <summary>Test row updating by mapped object.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestUpdateByMappedObject()
|
public void TestUpdateByMappedObject()
|
||||||
{
|
{
|
||||||
var u = GetTestTable();
|
var u = GetTestTable();
|
||||||
|
|
||||||
Assert.AreEqual(1, u.Update(update: new Users
|
Assert.AreEqual(1, u.Update(update: new Users
|
||||||
{
|
{
|
||||||
Id = 3,
|
Id = 3,
|
||||||
Code = "203",
|
Code = "203",
|
||||||
First = null,
|
First = null,
|
||||||
Last = "Gagarin",
|
Last = "Gagarin",
|
||||||
Email = "juri.gagarin@megacorp.com",
|
Email = "juri.gagarin@megacorp.com",
|
||||||
Quote = "bla, bla, bla"
|
Quote = "bla, bla, bla"
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
var o = u.Single(code: "203");
|
var o = u.Single(code: "203");
|
||||||
Assert.AreEqual(3, o.id);
|
Assert.AreEqual(3, o.id);
|
||||||
Assert.AreEqual("203", o.code.ToString());
|
Assert.AreEqual("203", o.code.ToString());
|
||||||
Assert.IsNull(o.first);
|
Assert.IsNull(o.first);
|
||||||
Assert.AreEqual("Gagarin", o.last);
|
Assert.AreEqual("Gagarin", o.last);
|
||||||
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
|
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
|
||||||
Assert.AreEqual("bla, bla, bla", o.quote);
|
Assert.AreEqual("bla, bla, bla", o.quote);
|
||||||
Assert.IsNull(o.password);
|
Assert.IsNull(o.password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test row updating by basic object.</summary>
|
/// <summary>Test row updating by basic object.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestUpdateByBasicObject()
|
public void TestUpdateByBasicObject()
|
||||||
{
|
{
|
||||||
var u = GetTestTable();
|
var u = GetTestTable();
|
||||||
|
|
||||||
Assert.AreEqual(1, u.Update(update: new users
|
Assert.AreEqual(1, u.Update(update: new users
|
||||||
{
|
{
|
||||||
id = 4,
|
id = 4,
|
||||||
code = "204",
|
code = "204",
|
||||||
first = null,
|
first = null,
|
||||||
last = "Gagarin",
|
last = "Gagarin",
|
||||||
email = "juri.gagarin@megacorp.com",
|
email = "juri.gagarin@megacorp.com",
|
||||||
quote = "bla, bla, bla"
|
quote = "bla, bla, bla"
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
var o = u.Single(code: "204");
|
var o = u.Single(code: "204");
|
||||||
Assert.AreEqual(4, o.id);
|
Assert.AreEqual(4, o.id);
|
||||||
Assert.AreEqual("204", o.code.ToString());
|
Assert.AreEqual("204", o.code.ToString());
|
||||||
Assert.IsNull(o.first);
|
Assert.IsNull(o.first);
|
||||||
Assert.AreEqual("Gagarin", o.last);
|
Assert.AreEqual("Gagarin", o.last);
|
||||||
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
|
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
|
||||||
Assert.AreEqual("bla, bla, bla", o.quote);
|
Assert.AreEqual("bla, bla, bla", o.quote);
|
||||||
Assert.IsNull(o.password);
|
Assert.IsNull(o.password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test row updating by dynamic objects.</summary>
|
/// <summary>Test row updating by dynamic objects.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestUpdateByDynamicObjects()
|
public void TestUpdateByDynamicObjects()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(1, GetTestTable().Update(values: new { code = "205", first = DBNull.Value, last = "Gagarin", email = "juri.gagarin@megacorp.com", quote = "bla, bla, bla" }, where: new { id = 5 }));
|
Assert.AreEqual(1, GetTestTable().Update(values: new { code = "205", first = DBNull.Value, last = "Gagarin", email = "juri.gagarin@megacorp.com", quote = "bla, bla, bla" }, where: new { id = 5 }));
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
var o = GetTestTable().Single(code: "205");
|
var o = GetTestTable().Single(code: "205");
|
||||||
Assert.AreEqual(5, o.id);
|
Assert.AreEqual(5, o.id);
|
||||||
Assert.AreEqual("205", o.code.ToString());
|
Assert.AreEqual("205", o.code.ToString());
|
||||||
Assert.IsNull(o.first);
|
Assert.IsNull(o.first);
|
||||||
Assert.AreEqual("Gagarin", o.last);
|
Assert.AreEqual("Gagarin", o.last);
|
||||||
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
|
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
|
||||||
Assert.AreEqual("bla, bla, bla", o.quote);
|
Assert.AreEqual("bla, bla, bla", o.quote);
|
||||||
Assert.IsNull(o.password);
|
Assert.IsNull(o.password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test row updating by mapped objects.</summary>
|
/// <summary>Test row updating by mapped objects.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestUpdateByMappedObjects()
|
public void TestUpdateByMappedObjects()
|
||||||
{
|
{
|
||||||
var u = GetTestTable();
|
var u = GetTestTable();
|
||||||
|
|
||||||
Assert.AreEqual(1, u.Update(values: new Users
|
Assert.AreEqual(1, u.Update(values: new Users
|
||||||
{
|
{
|
||||||
Id = 6,
|
Id = 6,
|
||||||
Code = "206",
|
Code = "206",
|
||||||
First = null,
|
First = null,
|
||||||
Last = "Gagarin",
|
Last = "Gagarin",
|
||||||
Email = "juri.gagarin@megacorp.com",
|
Email = "juri.gagarin@megacorp.com",
|
||||||
Quote = "bla, bla, bla"
|
Quote = "bla, bla, bla"
|
||||||
}, id: 6));
|
}, id: 6));
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
var o = u.Single(code: "206");
|
var o = u.Single(code: "206");
|
||||||
Assert.AreEqual(6, o.id);
|
Assert.AreEqual(6, o.id);
|
||||||
Assert.AreEqual("206", o.code.ToString());
|
Assert.AreEqual("206", o.code.ToString());
|
||||||
Assert.IsNull(o.first);
|
Assert.IsNull(o.first);
|
||||||
Assert.AreEqual("Gagarin", o.last);
|
Assert.AreEqual("Gagarin", o.last);
|
||||||
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
|
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
|
||||||
Assert.AreEqual("bla, bla, bla", o.quote);
|
Assert.AreEqual("bla, bla, bla", o.quote);
|
||||||
Assert.IsNull(o.password);
|
Assert.IsNull(o.password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test row updating by basic objects.</summary>
|
/// <summary>Test row updating by basic objects.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestUpdateByBasicObjects()
|
public void TestUpdateByBasicObjects()
|
||||||
{
|
{
|
||||||
var u = GetTestTable();
|
var u = GetTestTable();
|
||||||
|
|
||||||
Assert.AreEqual(1, u.Update(values: new users
|
Assert.AreEqual(1, u.Update(values: new users
|
||||||
{
|
{
|
||||||
id = 7,
|
id = 7,
|
||||||
code = "207",
|
code = "207",
|
||||||
first = null,
|
first = null,
|
||||||
last = "Gagarin",
|
last = "Gagarin",
|
||||||
email = "juri.gagarin@megacorp.com",
|
email = "juri.gagarin@megacorp.com",
|
||||||
quote = "bla, bla, bla"
|
quote = "bla, bla, bla"
|
||||||
}, id: 7));
|
}, id: 7));
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
var o = u.Single(code: "207");
|
var o = u.Single(code: "207");
|
||||||
Assert.AreEqual(7, o.id);
|
Assert.AreEqual(7, o.id);
|
||||||
Assert.AreEqual("207", o.code.ToString());
|
Assert.AreEqual("207", o.code.ToString());
|
||||||
Assert.IsNull(o.first);
|
Assert.IsNull(o.first);
|
||||||
Assert.AreEqual("Gagarin", o.last);
|
Assert.AreEqual("Gagarin", o.last);
|
||||||
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
|
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
|
||||||
Assert.AreEqual("bla, bla, bla", o.quote);
|
Assert.AreEqual("bla, bla, bla", o.quote);
|
||||||
Assert.IsNull(o.password);
|
Assert.IsNull(o.password);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Update
|
#endregion Update
|
||||||
|
|
||||||
#region Delete
|
#region Delete
|
||||||
|
|
||||||
/// <summary>Test row deleting by dynamic arguments.</summary>
|
/// <summary>Test row deleting by dynamic arguments.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestDeleteByArguments()
|
public void TestDeleteByArguments()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(1, GetTestTable().Delete(code: "10"));
|
Assert.AreEqual(1, GetTestTable().Delete(code: "10"));
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
Assert.AreEqual(0, GetTestTable().Count(code: "10"));
|
Assert.AreEqual(0, GetTestTable().Count(code: "10"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test row deleting by dynamic objects (all except ID should be ignored).</summary>
|
/// <summary>Test row deleting by dynamic objects (all except ID should be ignored).</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestDeleteyDynamicObject()
|
public void TestDeleteyDynamicObject()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(1, GetTestTable().Delete(delete: new { id = 11, code = 11, first = "Juri", last = "Gagarin", email = "juri.gagarin@megacorp.com", quote = "bla, bla, bla" }));
|
Assert.AreEqual(1, GetTestTable().Delete(delete: new { id = 11, code = 11, first = "Juri", last = "Gagarin", email = "juri.gagarin@megacorp.com", quote = "bla, bla, bla" }));
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
Assert.AreEqual(0, GetTestTable().Count(id: 11));
|
Assert.AreEqual(0, GetTestTable().Count(id: 11));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test row deleting by mapped object.</summary>
|
/// <summary>Test row deleting by mapped object.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestDeleteByMappedObject()
|
public void TestDeleteByMappedObject()
|
||||||
{
|
{
|
||||||
var u = GetTestTable();
|
var u = GetTestTable();
|
||||||
|
|
||||||
Assert.AreEqual(1, u.Delete(delete: new Users
|
Assert.AreEqual(1, u.Delete(delete: new Users
|
||||||
{
|
{
|
||||||
Id = 12,
|
Id = 12,
|
||||||
Code = "12",
|
Code = "12",
|
||||||
First = "Juri",
|
First = "Juri",
|
||||||
Last = "Gagarin",
|
Last = "Gagarin",
|
||||||
Email = "juri.gagarin@megacorp.com",
|
Email = "juri.gagarin@megacorp.com",
|
||||||
Quote = "bla, bla, bla"
|
Quote = "bla, bla, bla"
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
Assert.AreEqual(0, GetTestTable().Count(id: 12));
|
Assert.AreEqual(0, GetTestTable().Count(id: 12));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test row deleting by basic object.</summary>
|
/// <summary>Test row deleting by basic object.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestDeleteByBasicObject()
|
public void TestDeleteByBasicObject()
|
||||||
{
|
{
|
||||||
var u = GetTestTable();
|
var u = GetTestTable();
|
||||||
|
|
||||||
Assert.AreEqual(1, u.Delete(delete: new users
|
Assert.AreEqual(1, u.Delete(delete: new users
|
||||||
{
|
{
|
||||||
id = 13,
|
id = 13,
|
||||||
code = "13",
|
code = "13",
|
||||||
first = "Juri",
|
first = "Juri",
|
||||||
last = "Gagarin",
|
last = "Gagarin",
|
||||||
email = "juri.gagarin@megacorp.com",
|
email = "juri.gagarin@megacorp.com",
|
||||||
quote = "bla, bla, bla"
|
quote = "bla, bla, bla"
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
Assert.AreEqual(0, GetTestTable().Count(id: 13));
|
Assert.AreEqual(0, GetTestTable().Count(id: 13));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test row deleting by dynamic objects (all except ID should be ignored).</summary>
|
/// <summary>Test row deleting by dynamic objects (all except ID should be ignored).</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestDeleteyDynamicObjectWhere()
|
public void TestDeleteyDynamicObjectWhere()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(1, GetTestTable().Delete(where: new { id = 14, code = "14" }));
|
Assert.AreEqual(1, GetTestTable().Delete(where: new { id = 14, code = "14" }));
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
Assert.AreEqual(0, GetTestTable().Count(id: 14));
|
Assert.AreEqual(0, GetTestTable().Count(id: 14));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Delete
|
#endregion Delete
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,55 +1,55 @@
|
|||||||
/*
|
/*
|
||||||
* DynamORM - Dynamic Object-Relational Mapping library.
|
* DynamORM - Dynamic Object-Relational Mapping library.
|
||||||
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using NUnit.Framework;
|
||||||
|
|
||||||
namespace DynamORM.Tests.Modify
|
namespace DynamORM.Tests.Modify
|
||||||
{
|
{
|
||||||
/// <summary>Test standard dynamic access ORM. With out schema information from database.</summary>
|
/// <summary>Test standard dynamic access ORM. With out schema information from database.</summary>
|
||||||
[TestClass]
|
[TestFixture]
|
||||||
public class DynamicNoSchemaModificationTests : DynamicModificationTests
|
public class DynamicNoSchemaModificationTests : DynamicModificationTests
|
||||||
{
|
{
|
||||||
/// <summary>Setup test parameters.</summary>
|
/// <summary>Setup test parameters.</summary>
|
||||||
[TestInitialize]
|
[SetUp]
|
||||||
public virtual void SetUp()
|
public override void SetUp()
|
||||||
{
|
{
|
||||||
CreateTestDatabase();
|
CreateTestDatabase();
|
||||||
CreateDynamicDatabase(
|
CreateDynamicDatabase(
|
||||||
DynamicDatabaseOptions.SingleConnection |
|
DynamicDatabaseOptions.SingleConnection |
|
||||||
DynamicDatabaseOptions.SingleTransaction |
|
DynamicDatabaseOptions.SingleTransaction |
|
||||||
DynamicDatabaseOptions.SupportLimitOffset);
|
DynamicDatabaseOptions.SupportLimitOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Create table using specified method.</summary>
|
/// <summary>Create table using specified method.</summary>
|
||||||
/// <returns>Dynamic table.</returns>
|
/// <returns>Dynamic table.</returns>
|
||||||
public override dynamic GetTestTable()
|
public override dynamic GetTestTable()
|
||||||
{
|
{
|
||||||
return Database.Table("users", new string[] { "id" });
|
return Database.Table("users", new string[] { "id" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,69 +1,69 @@
|
|||||||
/*
|
/*
|
||||||
* DynamORM - Dynamic Object-Relational Mapping library.
|
* DynamORM - Dynamic Object-Relational Mapping library.
|
||||||
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using DynamORM.Tests.Helpers;
|
using DynamORM.Tests.Helpers;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using NUnit.Framework;
|
||||||
|
|
||||||
namespace DynamORM.Tests.Modify
|
namespace DynamORM.Tests.Modify
|
||||||
{
|
{
|
||||||
/// <summary>Test standard dynamic access ORM. With out schema information from database.</summary>
|
/// <summary>Test standard dynamic access ORM. With out schema information from database.</summary>
|
||||||
[TestClass]
|
[TestFixture]
|
||||||
public class DynamicTypeSchemaModificationTests : DynamicModificationTests
|
public class DynamicTypeSchemaModificationTests : DynamicModificationTests
|
||||||
{
|
{
|
||||||
/// <summary>Create table using specified method.</summary>
|
/// <summary>Create table using specified method.</summary>
|
||||||
/// <returns>Dynamic table.</returns>
|
/// <returns>Dynamic table.</returns>
|
||||||
public override dynamic GetTestTable()
|
public override dynamic GetTestTable()
|
||||||
{
|
{
|
||||||
return Database.Table<users>();
|
return Database.Table<users>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the bulk insert.
|
/// Tests the bulk insert.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestBulkInsert()
|
public void TestBulkInsert()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(2, Database.Insert<users>(new List<users>
|
Assert.AreEqual(2, Database.Insert<users>(new List<users>
|
||||||
{
|
{
|
||||||
new users
|
new users
|
||||||
{
|
{
|
||||||
id = 1001,
|
id = 1001,
|
||||||
login = "a",
|
login = "a",
|
||||||
},
|
},
|
||||||
new users
|
new users
|
||||||
{
|
{
|
||||||
id = 1002,
|
id = 1002,
|
||||||
login = "b",
|
login = "b",
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
Assert.AreEqual(2, Database.Delete<users>().Where(u => u.users.id.In(1001, 1002)).Execute());
|
Assert.AreEqual(2, Database.Delete<users>().Where(u => u.users.id.In(1001, 1002)).Execute());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,225 +1,225 @@
|
|||||||
/*
|
/*
|
||||||
* DynamORM - Dynamic Object-Relational Mapping library.
|
* DynamORM - Dynamic Object-Relational Mapping library.
|
||||||
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using DynamORM.Builders;
|
using DynamORM.Builders;
|
||||||
using DynamORM.Builders.Implementation;
|
using DynamORM.Builders.Implementation;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using NUnit.Framework;
|
||||||
using DynamORM.Tests.Helpers;
|
using DynamORM.Tests.Helpers;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using static System.Data.Entity.Infrastructure.Design.Executor;
|
using static System.Data.Entity.Infrastructure.Design.Executor;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace DynamORM.Tests.Modify
|
namespace DynamORM.Tests.Modify
|
||||||
{
|
{
|
||||||
/// <summary>New parser tests.</summary>
|
/// <summary>New parser tests.</summary>
|
||||||
[TestClass]
|
[TestFixture]
|
||||||
public class ParserTests : TestsBase
|
public class ParserTests : TestsBase
|
||||||
{
|
{
|
||||||
/// <summary>Setup test parameters.</summary>
|
/// <summary>Setup test parameters.</summary>
|
||||||
[TestInitialize]
|
[SetUp]
|
||||||
public virtual void SetUp()
|
public virtual void SetUp()
|
||||||
{
|
{
|
||||||
CreateTestDatabase();
|
CreateTestDatabase();
|
||||||
CreateDynamicDatabase(
|
CreateDynamicDatabase(
|
||||||
DynamicDatabaseOptions.SingleConnection |
|
DynamicDatabaseOptions.SingleConnection |
|
||||||
DynamicDatabaseOptions.SingleTransaction |
|
DynamicDatabaseOptions.SingleTransaction |
|
||||||
DynamicDatabaseOptions.SupportLimitOffset);
|
DynamicDatabaseOptions.SupportLimitOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Tear down test objects.</summary>
|
/// <summary>Tear down test objects.</summary>
|
||||||
[TestCleanup]
|
[TearDown]
|
||||||
public virtual void TearDown()
|
public virtual void TearDown()
|
||||||
{
|
{
|
||||||
DestroyDynamicDatabase();
|
DestroyDynamicDatabase();
|
||||||
DestroyTestDatabase();
|
DestroyTestDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Insert
|
#region Insert
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the basic insert.
|
/// Tests the basic insert.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestInsertBasic()
|
public void TestInsertBasic()
|
||||||
{
|
{
|
||||||
IDynamicInsertQueryBuilder cmd = new DynamicInsertQueryBuilder(Database, "Users");
|
IDynamicInsertQueryBuilder cmd = new DynamicInsertQueryBuilder(Database, "Users");
|
||||||
|
|
||||||
cmd.Values(x => x.Users.Code = "001", x => x.Users.Name = "Admin", x => x.Users.IsAdmin = 1);
|
cmd.Values(x => x.Users.Code = "001", x => x.Users.Name = "Admin", x => x.Users.IsAdmin = 1);
|
||||||
|
|
||||||
Assert.AreEqual(string.Format(@"INSERT INTO ""Users"" (""Code"", ""Name"", ""IsAdmin"") VALUES ({0})",
|
Assert.AreEqual(string.Format(@"INSERT INTO ""Users"" (""Code"", ""Name"", ""IsAdmin"") VALUES ({0})",
|
||||||
string.Join(", ", cmd.Parameters.Keys.Select(p => string.Format("[${0}]", p)))), cmd.CommandText());
|
string.Join(", ", cmd.Parameters.Keys.Select(p => string.Format("[${0}]", p)))), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the insert with sub query.
|
/// Tests the insert with sub query.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestInsertSubQuery()
|
public void TestInsertSubQuery()
|
||||||
{
|
{
|
||||||
IDynamicInsertQueryBuilder cmd = new DynamicInsertQueryBuilder(Database, "Users");
|
IDynamicInsertQueryBuilder cmd = new DynamicInsertQueryBuilder(Database, "Users");
|
||||||
|
|
||||||
cmd.Values(x => x.Code = "001", x => x.Name = "Admin", x => x.IsAdmin = x(cmd
|
cmd.Values(x => x.Code = "001", x => x.Name = "Admin", x => x.IsAdmin = x(cmd
|
||||||
.SubQuery(a => a.AccessRights.As(a.a))
|
.SubQuery(a => a.AccessRights.As(a.a))
|
||||||
.Select(a => a.IsAdmin)
|
.Select(a => a.IsAdmin)
|
||||||
.Where(a => a.User_Id == "001")));
|
.Where(a => a.User_Id == "001")));
|
||||||
|
|
||||||
Assert.AreEqual(string.Format(@"INSERT INTO ""Users"" (""Code"", ""Name"", ""IsAdmin"") VALUES ({0}, (SELECT a.""IsAdmin"" FROM ""AccessRights"" AS a WHERE (a.""User_Id"" = [${1}])))",
|
Assert.AreEqual(string.Format(@"INSERT INTO ""Users"" (""Code"", ""Name"", ""IsAdmin"") VALUES ({0}, (SELECT a.""IsAdmin"" FROM ""AccessRights"" AS a WHERE (a.""User_Id"" = [${1}])))",
|
||||||
string.Join(", ", cmd.Parameters.Keys.Take(2).Select(p => string.Format("[${0}]", p))), cmd.Parameters.Keys.Last()), cmd.CommandText());
|
string.Join(", ", cmd.Parameters.Keys.Take(2).Select(p => string.Format("[${0}]", p))), cmd.Parameters.Keys.Last()), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the basic insert using object.
|
/// Tests the basic insert using object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestInsertBasicObject()
|
public void TestInsertBasicObject()
|
||||||
{
|
{
|
||||||
IDynamicInsertQueryBuilder cmd = new DynamicInsertQueryBuilder(Database, "Users");
|
IDynamicInsertQueryBuilder cmd = new DynamicInsertQueryBuilder(Database, "Users");
|
||||||
|
|
||||||
cmd.Values(x => new { Code = "001", Name = "Admin", IsAdmin = 1 });
|
cmd.Values(x => new { Code = "001", Name = "Admin", IsAdmin = 1 });
|
||||||
|
|
||||||
Assert.AreEqual(string.Format(@"INSERT INTO ""Users"" (""Code"", ""Name"", ""IsAdmin"") VALUES ({0})",
|
Assert.AreEqual(string.Format(@"INSERT INTO ""Users"" (""Code"", ""Name"", ""IsAdmin"") VALUES ({0})",
|
||||||
string.Join(", ", cmd.Parameters.Keys.Select(p => string.Format("[${0}]", p)))), cmd.CommandText());
|
string.Join(", ", cmd.Parameters.Keys.Select(p => string.Format("[${0}]", p)))), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the insert using object with sub query.
|
/// Tests the insert using object with sub query.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestInsertSubQueryObject()
|
public void TestInsertSubQueryObject()
|
||||||
{
|
{
|
||||||
IDynamicInsertQueryBuilder cmd = new DynamicInsertQueryBuilder(Database, "Users");
|
IDynamicInsertQueryBuilder cmd = new DynamicInsertQueryBuilder(Database, "Users");
|
||||||
|
|
||||||
cmd.Values(x => new
|
cmd.Values(x => new
|
||||||
{
|
{
|
||||||
Code = "001",
|
Code = "001",
|
||||||
Name = "Admin",
|
Name = "Admin",
|
||||||
IsAdmin = x(cmd
|
IsAdmin = x(cmd
|
||||||
.SubQuery(a => a.AccessRights.As(a.a))
|
.SubQuery(a => a.AccessRights.As(a.a))
|
||||||
.Select(a => a.IsAdmin)
|
.Select(a => a.IsAdmin)
|
||||||
.Where(a => a.User_Id == "001"))
|
.Where(a => a.User_Id == "001"))
|
||||||
});
|
});
|
||||||
|
|
||||||
Assert.AreEqual(string.Format(@"INSERT INTO ""Users"" (""Code"", ""Name"", ""IsAdmin"") VALUES ({0}, (SELECT a.""IsAdmin"" FROM ""AccessRights"" AS a WHERE (a.""User_Id"" = [${1}])))",
|
Assert.AreEqual(string.Format(@"INSERT INTO ""Users"" (""Code"", ""Name"", ""IsAdmin"") VALUES ({0}, (SELECT a.""IsAdmin"" FROM ""AccessRights"" AS a WHERE (a.""User_Id"" = [${1}])))",
|
||||||
string.Join(", ", cmd.Parameters.Keys.Take(2).Select(p => string.Format("[${0}]", p))), cmd.Parameters.Keys.Last()), cmd.CommandText());
|
string.Join(", ", cmd.Parameters.Keys.Take(2).Select(p => string.Format("[${0}]", p))), cmd.Parameters.Keys.Last()), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Insert
|
#endregion Insert
|
||||||
|
|
||||||
#region Update
|
#region Update
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the basic update.
|
/// Tests the basic update.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestUpdateBasicSet()
|
public void TestUpdateBasicSet()
|
||||||
{
|
{
|
||||||
IDynamicUpdateQueryBuilder cmd = new DynamicUpdateQueryBuilder(Database, "Users");
|
IDynamicUpdateQueryBuilder cmd = new DynamicUpdateQueryBuilder(Database, "Users");
|
||||||
|
|
||||||
cmd.Set(x => x.Users.Code = "001", x => x.Users.Name = "Admin", x => x.Users.IsAdmin = 1)
|
cmd.Set(x => x.Users.Code = "001", x => x.Users.Name = "Admin", x => x.Users.IsAdmin = 1)
|
||||||
.Where(x => x.Users.Id_User == 1);
|
.Where(x => x.Users.Id_User == 1);
|
||||||
|
|
||||||
Assert.AreEqual(string.Format(@"UPDATE ""Users"" SET ""Code"" = [${0}], ""Name"" = [${1}], ""IsAdmin"" = [${2}] WHERE (""Users"".""Id_User"" = [${3}])",
|
Assert.AreEqual(string.Format(@"UPDATE ""Users"" SET ""Code"" = [${0}], ""Name"" = [${1}], ""IsAdmin"" = [${2}] WHERE (""Users"".""Id_User"" = [${3}])",
|
||||||
cmd.Parameters.Keys.ToArray()[0], cmd.Parameters.Keys.ToArray()[1], cmd.Parameters.Keys.ToArray()[2], cmd.Parameters.Keys.ToArray()[3]), cmd.CommandText());
|
cmd.Parameters.Keys.ToArray()[0], cmd.Parameters.Keys.ToArray()[1], cmd.Parameters.Keys.ToArray()[2], cmd.Parameters.Keys.ToArray()[3]), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the basic update.
|
/// Tests the basic update.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestUpdateBasicValues()
|
public void TestUpdateBasicValues()
|
||||||
{
|
{
|
||||||
IDynamicUpdateQueryBuilder cmd = new DynamicUpdateQueryBuilder(Database, "Users");
|
IDynamicUpdateQueryBuilder cmd = new DynamicUpdateQueryBuilder(Database, "Users");
|
||||||
|
|
||||||
cmd
|
cmd
|
||||||
.Values("Code", "001")
|
.Values("Code", "001")
|
||||||
.Values("Name", "Admin")
|
.Values("Name", "Admin")
|
||||||
.Values("IsAdmin", "1")
|
.Values("IsAdmin", "1")
|
||||||
.Where(x => x.Users.Id_User == 1);
|
.Where(x => x.Users.Id_User == 1);
|
||||||
|
|
||||||
Assert.AreEqual(string.Format(@"UPDATE ""Users"" SET ""Code"" = [${0}], ""Name"" = [${1}], ""IsAdmin"" = [${2}] WHERE (""Users"".""Id_User"" = [${3}])",
|
Assert.AreEqual(string.Format(@"UPDATE ""Users"" SET ""Code"" = [${0}], ""Name"" = [${1}], ""IsAdmin"" = [${2}] WHERE (""Users"".""Id_User"" = [${3}])",
|
||||||
cmd.Parameters.Keys.ToArray()[0], cmd.Parameters.Keys.ToArray()[1], cmd.Parameters.Keys.ToArray()[2], cmd.Parameters.Keys.ToArray()[3]), cmd.CommandText());
|
cmd.Parameters.Keys.ToArray()[0], cmd.Parameters.Keys.ToArray()[1], cmd.Parameters.Keys.ToArray()[2], cmd.Parameters.Keys.ToArray()[3]), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the insert with sub query.
|
/// Tests the insert with sub query.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestUpdateSubQuery()
|
public void TestUpdateSubQuery()
|
||||||
{
|
{
|
||||||
IDynamicUpdateQueryBuilder cmd = new DynamicUpdateQueryBuilder(Database, "Users");
|
IDynamicUpdateQueryBuilder cmd = new DynamicUpdateQueryBuilder(Database, "Users");
|
||||||
cmd.Set(x => x.Users.Code = "001", x => x.Users.Name = "Admin", x => x.Users.IsAdmin = x(cmd
|
cmd.Set(x => x.Users.Code = "001", x => x.Users.Name = "Admin", x => x.Users.IsAdmin = x(cmd
|
||||||
.SubQuery(a => a.AccessRights.As(a.a))
|
.SubQuery(a => a.AccessRights.As(a.a))
|
||||||
.Select(a => a.IsAdmin)
|
.Select(a => a.IsAdmin)
|
||||||
.Where(a => a.User_Id == a.Users.Id_User)))
|
.Where(a => a.User_Id == a.Users.Id_User)))
|
||||||
.Where(x => x.Users.Id_User == 1);
|
.Where(x => x.Users.Id_User == 1);
|
||||||
|
|
||||||
Assert.AreEqual(string.Format(@"UPDATE ""Users"" SET ""Code"" = [${0}], ""Name"" = [${1}], ""IsAdmin"" = (SELECT a.""IsAdmin"" FROM ""AccessRights"" AS a WHERE (a.""User_Id"" = ""Users"".""Id_User"")) WHERE (""Users"".""Id_User"" = [${2}])",
|
Assert.AreEqual(string.Format(@"UPDATE ""Users"" SET ""Code"" = [${0}], ""Name"" = [${1}], ""IsAdmin"" = (SELECT a.""IsAdmin"" FROM ""AccessRights"" AS a WHERE (a.""User_Id"" = ""Users"".""Id_User"")) WHERE (""Users"".""Id_User"" = [${2}])",
|
||||||
cmd.Parameters.Keys.ToArray()[0], cmd.Parameters.Keys.ToArray()[1], cmd.Parameters.Keys.ToArray()[2]), cmd.CommandText());
|
cmd.Parameters.Keys.ToArray()[0], cmd.Parameters.Keys.ToArray()[1], cmd.Parameters.Keys.ToArray()[2]), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the basic insert using object.
|
/// Tests the basic insert using object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestUpdateBasicObject()
|
public void TestUpdateBasicObject()
|
||||||
{
|
{
|
||||||
IDynamicUpdateQueryBuilder cmd = new DynamicUpdateQueryBuilder(Database, "Users");
|
IDynamicUpdateQueryBuilder cmd = new DynamicUpdateQueryBuilder(Database, "Users");
|
||||||
|
|
||||||
cmd.Set(x => new { Code = "001", Name = "Admin", IsAdmin = 1 })
|
cmd.Set(x => new { Code = "001", Name = "Admin", IsAdmin = 1 })
|
||||||
.Where(x => new { Id_User = 1 });
|
.Where(x => new { Id_User = 1 });
|
||||||
|
|
||||||
Assert.AreEqual(string.Format(@"UPDATE ""Users"" SET ""Code"" = [${0}], ""Name"" = [${1}], ""IsAdmin"" = [${2}] WHERE (""Id_User"" = [${3}])",
|
Assert.AreEqual(string.Format(@"UPDATE ""Users"" SET ""Code"" = [${0}], ""Name"" = [${1}], ""IsAdmin"" = [${2}] WHERE (""Id_User"" = [${3}])",
|
||||||
cmd.Parameters.Keys.ToArray()[0], cmd.Parameters.Keys.ToArray()[1], cmd.Parameters.Keys.ToArray()[2], cmd.Parameters.Keys.ToArray()[3]), cmd.CommandText());
|
cmd.Parameters.Keys.ToArray()[0], cmd.Parameters.Keys.ToArray()[1], cmd.Parameters.Keys.ToArray()[2], cmd.Parameters.Keys.ToArray()[3]), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the basic insert using object.
|
/// Tests the basic insert using object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestUpdateSubQueryObject()
|
public void TestUpdateSubQueryObject()
|
||||||
{
|
{
|
||||||
IDynamicUpdateQueryBuilder cmd = new DynamicUpdateQueryBuilder(Database, "Users");
|
IDynamicUpdateQueryBuilder cmd = new DynamicUpdateQueryBuilder(Database, "Users");
|
||||||
|
|
||||||
cmd.Set(x => new
|
cmd.Set(x => new
|
||||||
{
|
{
|
||||||
Code = "001",
|
Code = "001",
|
||||||
Name = "Admin",
|
Name = "Admin",
|
||||||
IsAdmin = x(cmd
|
IsAdmin = x(cmd
|
||||||
.SubQuery(a => a.AccessRights.As(a.a))
|
.SubQuery(a => a.AccessRights.As(a.a))
|
||||||
.Select(a => a.IsAdmin)
|
.Select(a => a.IsAdmin)
|
||||||
.Where(a => a.User_Id == a.Users.Id_User))
|
.Where(a => a.User_Id == a.Users.Id_User))
|
||||||
}).Where(x => new { Id_User = 1 });
|
}).Where(x => new { Id_User = 1 });
|
||||||
|
|
||||||
Assert.AreEqual(string.Format(@"UPDATE ""Users"" SET ""Code"" = [${0}], ""Name"" = [${1}], ""IsAdmin"" = (SELECT a.""IsAdmin"" FROM ""AccessRights"" AS a WHERE (a.""User_Id"" = ""Users"".""Id_User"")) WHERE (""Id_User"" = [${2}])",
|
Assert.AreEqual(string.Format(@"UPDATE ""Users"" SET ""Code"" = [${0}], ""Name"" = [${1}], ""IsAdmin"" = (SELECT a.""IsAdmin"" FROM ""AccessRights"" AS a WHERE (a.""User_Id"" = ""Users"".""Id_User"")) WHERE (""Id_User"" = [${2}])",
|
||||||
cmd.Parameters.Keys.ToArray()[0], cmd.Parameters.Keys.ToArray()[1], cmd.Parameters.Keys.ToArray()[2]), cmd.CommandText());
|
cmd.Parameters.Keys.ToArray()[0], cmd.Parameters.Keys.ToArray()[1], cmd.Parameters.Keys.ToArray()[2]), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Update
|
#endregion Update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,55 +1,55 @@
|
|||||||
/*
|
/*
|
||||||
* DynamORM - Dynamic Object-Relational Mapping library.
|
* DynamORM - Dynamic Object-Relational Mapping library.
|
||||||
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using NUnit.Framework;
|
||||||
|
|
||||||
namespace DynamORM.Tests.Select
|
namespace DynamORM.Tests.Select
|
||||||
{
|
{
|
||||||
/// <summary>Test standard dynamic access ORM. With out schema information from database.</summary>
|
/// <summary>Test standard dynamic access ORM. With out schema information from database.</summary>
|
||||||
[TestClass]
|
[TestFixture]
|
||||||
public class DynamicNoSchemaAccessTests : DynamicAccessTests
|
public class DynamicNoSchemaAccessTests : DynamicAccessTests
|
||||||
{
|
{
|
||||||
/// <summary>Setup test parameters.</summary>
|
/// <summary>Setup test parameters.</summary>
|
||||||
[TestInitialize]
|
[SetUp]
|
||||||
public override void SetUp()
|
public override void SetUp()
|
||||||
{
|
{
|
||||||
CreateTestDatabase();
|
CreateTestDatabase();
|
||||||
CreateDynamicDatabase(
|
CreateDynamicDatabase(
|
||||||
DynamicDatabaseOptions.SingleConnection |
|
DynamicDatabaseOptions.SingleConnection |
|
||||||
DynamicDatabaseOptions.SingleTransaction |
|
DynamicDatabaseOptions.SingleTransaction |
|
||||||
DynamicDatabaseOptions.SupportLimitOffset);
|
DynamicDatabaseOptions.SupportLimitOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Create table using specified method.</summary>
|
/// <summary>Create table using specified method.</summary>
|
||||||
/// <returns>Dynamic table.</returns>
|
/// <returns>Dynamic table.</returns>
|
||||||
public override dynamic GetTestTable()
|
public override dynamic GetTestTable()
|
||||||
{
|
{
|
||||||
return Database.Table("users", new string[] { "id" });
|
return Database.Table("users", new string[] { "id" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,45 +1,45 @@
|
|||||||
/*
|
/*
|
||||||
* DynamORM - Dynamic Object-Relational Mapping library.
|
* DynamORM - Dynamic Object-Relational Mapping library.
|
||||||
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using DynamORM.Tests.Helpers;
|
using DynamORM.Tests.Helpers;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using NUnit.Framework;
|
||||||
|
|
||||||
namespace DynamORM.Tests.Select
|
namespace DynamORM.Tests.Select
|
||||||
{
|
{
|
||||||
/// <summary>Test standard dynamic access ORM. With out schema information from database.</summary>
|
/// <summary>Test standard dynamic access ORM. With out schema information from database.</summary>
|
||||||
[TestClass]
|
[TestFixture]
|
||||||
public class DynamicTypeSchemaAccessTests : DynamicNoSchemaAccessTests
|
public class DynamicTypeSchemaAccessTests : DynamicNoSchemaAccessTests
|
||||||
{
|
{
|
||||||
/// <summary>Create table using specified method.</summary>
|
/// <summary>Create table using specified method.</summary>
|
||||||
/// <returns>Dynamic table.</returns>
|
/// <returns>Dynamic table.</returns>
|
||||||
public override dynamic GetTestTable()
|
public override dynamic GetTestTable()
|
||||||
{
|
{
|
||||||
return Database.Table<users>();
|
return Database.Table<users>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,321 +1,321 @@
|
|||||||
/*
|
/*
|
||||||
* DynamORM - Dynamic Object-Relational Mapping library.
|
* DynamORM - Dynamic Object-Relational Mapping library.
|
||||||
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using DynamORM.Builders;
|
using DynamORM.Builders;
|
||||||
using DynamORM.Builders.Implementation;
|
using DynamORM.Builders.Implementation;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using NUnit.Framework;
|
||||||
|
|
||||||
namespace DynamORM.Tests.Select
|
namespace DynamORM.Tests.Select
|
||||||
{
|
{
|
||||||
/// <summary>Tests of legacy parser methods.</summary>
|
/// <summary>Tests of legacy parser methods.</summary>
|
||||||
[TestClass]
|
[TestFixture]
|
||||||
public class LegacyParserTests : TestsBase
|
public class LegacyParserTests : TestsBase
|
||||||
{
|
{
|
||||||
/// <summary>Setup test parameters.</summary>
|
/// <summary>Setup test parameters.</summary>
|
||||||
[TestInitialize]
|
[SetUp]
|
||||||
public virtual void SetUp()
|
public virtual void SetUp()
|
||||||
{
|
{
|
||||||
CreateTestDatabase();
|
CreateTestDatabase();
|
||||||
CreateDynamicDatabase(
|
CreateDynamicDatabase(
|
||||||
DynamicDatabaseOptions.SingleConnection |
|
DynamicDatabaseOptions.SingleConnection |
|
||||||
DynamicDatabaseOptions.SingleTransaction |
|
DynamicDatabaseOptions.SingleTransaction |
|
||||||
DynamicDatabaseOptions.SupportLimitOffset);
|
DynamicDatabaseOptions.SupportLimitOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Tear down test objects.</summary>
|
/// <summary>Tear down test objects.</summary>
|
||||||
[TestCleanup]
|
[TearDown]
|
||||||
public virtual void TearDown()
|
public virtual void TearDown()
|
||||||
{
|
{
|
||||||
DestroyDynamicDatabase();
|
DestroyDynamicDatabase();
|
||||||
DestroyTestDatabase();
|
DestroyTestDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the where expression equal.
|
/// Tests the where expression equal.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestWhereEq()
|
public void TestWhereEq()
|
||||||
{
|
{
|
||||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||||
|
|
||||||
cmd.From(x => x.dbo.Users.As(x.u))
|
cmd.From(x => x.dbo.Users.As(x.u))
|
||||||
.Where(new DynamicColumn("u.Deleted").Eq(0));
|
.Where(new DynamicColumn("u.Deleted").Eq(0));
|
||||||
|
|
||||||
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE (u.\"Deleted\" = [${0}])", cmd.Parameters.Keys.First()), cmd.CommandText());
|
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE (u.\"Deleted\" = [${0}])", cmd.Parameters.Keys.First()), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the where expression equal with brackets.
|
/// Tests the where expression equal with brackets.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestWhereBracketsEq()
|
public void TestWhereBracketsEq()
|
||||||
{
|
{
|
||||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||||
|
|
||||||
cmd.From(x => x.dbo.Users.As(x.u))
|
cmd.From(x => x.dbo.Users.As(x.u))
|
||||||
.Where(new DynamicColumn("u.Deleted").Eq(0).SetBeginBlock())
|
.Where(new DynamicColumn("u.Deleted").Eq(0).SetBeginBlock())
|
||||||
.Where(new DynamicColumn("u.IsActive").Eq(1).SetEndBlock());
|
.Where(new DynamicColumn("u.IsActive").Eq(1).SetEndBlock());
|
||||||
|
|
||||||
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE ((u.\"Deleted\" = [${0}]) AND (u.\"IsActive\" = [${1}]))", cmd.Parameters.Keys.First(), cmd.Parameters.Keys.Last()), cmd.CommandText());
|
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE ((u.\"Deleted\" = [${0}]) AND (u.\"IsActive\" = [${1}]))", cmd.Parameters.Keys.First(), cmd.Parameters.Keys.Last()), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the where expression equal with brackets and or condition.
|
/// Tests the where expression equal with brackets and or condition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestWhereBracketsOrEq()
|
public void TestWhereBracketsOrEq()
|
||||||
{
|
{
|
||||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||||
|
|
||||||
cmd.From(x => x.dbo.Users.As(x.u))
|
cmd.From(x => x.dbo.Users.As(x.u))
|
||||||
.Where(new DynamicColumn("u.Deleted").Eq(0).SetBeginBlock())
|
.Where(new DynamicColumn("u.Deleted").Eq(0).SetBeginBlock())
|
||||||
.Where(new DynamicColumn("u.IsActive").Eq(1).SetOr().SetEndBlock());
|
.Where(new DynamicColumn("u.IsActive").Eq(1).SetOr().SetEndBlock());
|
||||||
|
|
||||||
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE ((u.\"Deleted\" = [${0}]) OR (u.\"IsActive\" = [${1}]))", cmd.Parameters.Keys.First(), cmd.Parameters.Keys.Last()), cmd.CommandText());
|
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE ((u.\"Deleted\" = [${0}]) OR (u.\"IsActive\" = [${1}]))", cmd.Parameters.Keys.First(), cmd.Parameters.Keys.Last()), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the where expression equal with brackets.
|
/// Tests the where expression equal with brackets.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestWhereBracketsOrEq2()
|
public void TestWhereBracketsOrEq2()
|
||||||
{
|
{
|
||||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||||
|
|
||||||
cmd.From(x => x.dbo.Users.As(x.u))
|
cmd.From(x => x.dbo.Users.As(x.u))
|
||||||
.Where(new DynamicColumn("u.Id_User").Greater(1))
|
.Where(new DynamicColumn("u.Id_User").Greater(1))
|
||||||
.Where(new DynamicColumn("u.Deleted").Eq(0).SetBeginBlock())
|
.Where(new DynamicColumn("u.Deleted").Eq(0).SetBeginBlock())
|
||||||
.Where(new DynamicColumn("u.IsActive").Eq(1).SetOr().SetEndBlock());
|
.Where(new DynamicColumn("u.IsActive").Eq(1).SetOr().SetEndBlock());
|
||||||
|
|
||||||
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE (u.\"Id_User\" > [${0}]) AND ((u.\"Deleted\" = [${1}]) OR (u.\"IsActive\" = [${2}]))",
|
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE (u.\"Id_User\" > [${0}]) AND ((u.\"Deleted\" = [${1}]) OR (u.\"IsActive\" = [${2}]))",
|
||||||
cmd.Parameters.Keys.ToArray()[0], cmd.Parameters.Keys.ToArray()[1], cmd.Parameters.Keys.ToArray()[2]), cmd.CommandText());
|
cmd.Parameters.Keys.ToArray()[0], cmd.Parameters.Keys.ToArray()[1], cmd.Parameters.Keys.ToArray()[2]), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the where expression equal with brackets.
|
/// Tests the where expression equal with brackets.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestWhereBracketsOrEqForgotToEnd()
|
public void TestWhereBracketsOrEqForgotToEnd()
|
||||||
{
|
{
|
||||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||||
|
|
||||||
cmd.From(x => x.dbo.Users.As(x.u))
|
cmd.From(x => x.dbo.Users.As(x.u))
|
||||||
.Where(new DynamicColumn("u.Id_User").Greater(1))
|
.Where(new DynamicColumn("u.Id_User").Greater(1))
|
||||||
.Where(new DynamicColumn("u.Deleted").Eq(0).SetBeginBlock())
|
.Where(new DynamicColumn("u.Deleted").Eq(0).SetBeginBlock())
|
||||||
.Where(new DynamicColumn("u.IsActive").Eq(1).SetOr());
|
.Where(new DynamicColumn("u.IsActive").Eq(1).SetOr());
|
||||||
|
|
||||||
using (var con = Database.Open())
|
using (var con = Database.Open())
|
||||||
using (var c = con.CreateCommand())
|
using (var c = con.CreateCommand())
|
||||||
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE (u.\"Id_User\" > @0) AND ((u.\"Deleted\" = @1) OR (u.\"IsActive\" = @2))"),
|
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE (u.\"Id_User\" > @0) AND ((u.\"Deleted\" = @1) OR (u.\"IsActive\" = @2))"),
|
||||||
c.SetCommand(cmd).CommandText);
|
c.SetCommand(cmd).CommandText);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the where expression not equal.
|
/// Tests the where expression not equal.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestWhereNotEq()
|
public void TestWhereNotEq()
|
||||||
{
|
{
|
||||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||||
|
|
||||||
cmd.From(x => x.dbo.Users.As(x.u))
|
cmd.From(x => x.dbo.Users.As(x.u))
|
||||||
.Where(new DynamicColumn("u.Deleted").Not(0));
|
.Where(new DynamicColumn("u.Deleted").Not(0));
|
||||||
|
|
||||||
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE (u.\"Deleted\" <> [${0}])", cmd.Parameters.Keys.First()), cmd.CommandText());
|
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE (u.\"Deleted\" <> [${0}])", cmd.Parameters.Keys.First()), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the where expression greater.
|
/// Tests the where expression greater.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestWhereGreater()
|
public void TestWhereGreater()
|
||||||
{
|
{
|
||||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||||
|
|
||||||
cmd.From(x => x.dbo.Users.As(x.u))
|
cmd.From(x => x.dbo.Users.As(x.u))
|
||||||
.Where(new DynamicColumn("u.Deleted").Greater(0));
|
.Where(new DynamicColumn("u.Deleted").Greater(0));
|
||||||
|
|
||||||
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE (u.\"Deleted\" > [${0}])", cmd.Parameters.Keys.First()), cmd.CommandText());
|
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE (u.\"Deleted\" > [${0}])", cmd.Parameters.Keys.First()), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the where expression greater or equal.
|
/// Tests the where expression greater or equal.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestWhereGreaterOrEqual()
|
public void TestWhereGreaterOrEqual()
|
||||||
{
|
{
|
||||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||||
|
|
||||||
cmd.From(x => x.dbo.Users.As(x.u))
|
cmd.From(x => x.dbo.Users.As(x.u))
|
||||||
.Where(new DynamicColumn("u.Deleted").GreaterOrEqual(0));
|
.Where(new DynamicColumn("u.Deleted").GreaterOrEqual(0));
|
||||||
|
|
||||||
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE (u.\"Deleted\" >= [${0}])", cmd.Parameters.Keys.First()), cmd.CommandText());
|
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE (u.\"Deleted\" >= [${0}])", cmd.Parameters.Keys.First()), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the where expression less.
|
/// Tests the where expression less.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestWhereLess()
|
public void TestWhereLess()
|
||||||
{
|
{
|
||||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||||
|
|
||||||
cmd.From(x => x.dbo.Users.As(x.u))
|
cmd.From(x => x.dbo.Users.As(x.u))
|
||||||
.Where(new DynamicColumn("u.Deleted").Less(1));
|
.Where(new DynamicColumn("u.Deleted").Less(1));
|
||||||
|
|
||||||
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE (u.\"Deleted\" < [${0}])", cmd.Parameters.Keys.First()), cmd.CommandText());
|
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE (u.\"Deleted\" < [${0}])", cmd.Parameters.Keys.First()), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the where expression less or equal.
|
/// Tests the where expression less or equal.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestWhereLessOrEqual()
|
public void TestWhereLessOrEqual()
|
||||||
{
|
{
|
||||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||||
|
|
||||||
cmd.From(x => x.dbo.Users.As(x.u))
|
cmd.From(x => x.dbo.Users.As(x.u))
|
||||||
.Where(new DynamicColumn("u.Deleted").LessOrEqual(1));
|
.Where(new DynamicColumn("u.Deleted").LessOrEqual(1));
|
||||||
|
|
||||||
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE (u.\"Deleted\" <= [${0}])", cmd.Parameters.Keys.First()), cmd.CommandText());
|
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE (u.\"Deleted\" <= [${0}])", cmd.Parameters.Keys.First()), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the where expression like.
|
/// Tests the where expression like.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestWhereLike()
|
public void TestWhereLike()
|
||||||
{
|
{
|
||||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||||
|
|
||||||
cmd.From(x => x.dbo.Users.As(x.u))
|
cmd.From(x => x.dbo.Users.As(x.u))
|
||||||
.Where(new DynamicColumn("u.Deleted").Like("%1"));
|
.Where(new DynamicColumn("u.Deleted").Like("%1"));
|
||||||
|
|
||||||
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE u.\"Deleted\" LIKE [${0}]", cmd.Parameters.Keys.First()), cmd.CommandText());
|
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE u.\"Deleted\" LIKE [${0}]", cmd.Parameters.Keys.First()), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the where expression not like.
|
/// Tests the where expression not like.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestWhereNotLike()
|
public void TestWhereNotLike()
|
||||||
{
|
{
|
||||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||||
|
|
||||||
cmd.From(x => x.dbo.Users.As(x.u))
|
cmd.From(x => x.dbo.Users.As(x.u))
|
||||||
.Where(new DynamicColumn("u.Deleted").NotLike("%1"));
|
.Where(new DynamicColumn("u.Deleted").NotLike("%1"));
|
||||||
|
|
||||||
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE u.\"Deleted\" NOT LIKE [${0}]", cmd.Parameters.Keys.First()), cmd.CommandText());
|
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE u.\"Deleted\" NOT LIKE [${0}]", cmd.Parameters.Keys.First()), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the where expression between.
|
/// Tests the where expression between.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestWhereBetween()
|
public void TestWhereBetween()
|
||||||
{
|
{
|
||||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||||
|
|
||||||
cmd.From(x => x.dbo.Users.As(x.u))
|
cmd.From(x => x.dbo.Users.As(x.u))
|
||||||
.Where(new DynamicColumn("u.Deleted").Between(0, 1));
|
.Where(new DynamicColumn("u.Deleted").Between(0, 1));
|
||||||
|
|
||||||
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE u.\"Deleted\" BETWEEN [${0}] AND [${1}]", cmd.Parameters.Keys.First(), cmd.Parameters.Keys.Last()), cmd.CommandText());
|
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE u.\"Deleted\" BETWEEN [${0}] AND [${1}]", cmd.Parameters.Keys.First(), cmd.Parameters.Keys.Last()), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the where expression in.
|
/// Tests the where expression in.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestWhereIn()
|
public void TestWhereIn()
|
||||||
{
|
{
|
||||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||||
|
|
||||||
cmd.From(x => x.dbo.Users.As(x.u))
|
cmd.From(x => x.dbo.Users.As(x.u))
|
||||||
.Where(new DynamicColumn("u.Deleted").In(0, 1));
|
.Where(new DynamicColumn("u.Deleted").In(0, 1));
|
||||||
|
|
||||||
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE u.\"Deleted\" IN([${0}], [${1}])", cmd.Parameters.Keys.First(), cmd.Parameters.Keys.Last()), cmd.CommandText());
|
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE u.\"Deleted\" IN([${0}], [${1}])", cmd.Parameters.Keys.First(), cmd.Parameters.Keys.Last()), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the where expression using anonymous types.
|
/// Tests the where expression using anonymous types.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestWhereAnon()
|
public void TestWhereAnon()
|
||||||
{
|
{
|
||||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||||
|
|
||||||
cmd.From(x => x.dbo.Users.As(x.u))
|
cmd.From(x => x.dbo.Users.As(x.u))
|
||||||
.Where(new { Deleted = 0, IsActive = 1, _table = "u" });
|
.Where(new { Deleted = 0, IsActive = 1, _table = "u" });
|
||||||
|
|
||||||
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE (u.\"Deleted\" = [${0}]) AND (u.\"IsActive\" = [${1}])", cmd.Parameters.Keys.First(), cmd.Parameters.Keys.Last()), cmd.CommandText());
|
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u WHERE (u.\"Deleted\" = [${0}]) AND (u.\"IsActive\" = [${1}])", cmd.Parameters.Keys.First(), cmd.Parameters.Keys.Last()), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the order by column.
|
/// Tests the order by column.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestOrderByCol()
|
public void TestOrderByCol()
|
||||||
{
|
{
|
||||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||||
|
|
||||||
cmd.From(x => x.dbo.Users.As(x.u))
|
cmd.From(x => x.dbo.Users.As(x.u))
|
||||||
.OrderByColumn(new DynamicColumn("u.Name").Desc());
|
.OrderByColumn(new DynamicColumn("u.Name").Desc());
|
||||||
|
|
||||||
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u ORDER BY u.\"Name\" DESC"), cmd.CommandText());
|
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u ORDER BY u.\"Name\" DESC"), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the order by column number.
|
/// Tests the order by column number.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestOrderByNum()
|
public void TestOrderByNum()
|
||||||
{
|
{
|
||||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||||
|
|
||||||
cmd.From(x => x.dbo.Users.As(x.u))
|
cmd.From(x => x.dbo.Users.As(x.u))
|
||||||
.OrderByColumn(new DynamicColumn("u.Name").SetAlias("1").Desc());
|
.OrderByColumn(new DynamicColumn("u.Name").SetAlias("1").Desc());
|
||||||
|
|
||||||
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u ORDER BY 1 DESC"), cmd.CommandText());
|
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u ORDER BY 1 DESC"), cmd.CommandText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the group by column.
|
/// Tests the group by column.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public void TestGroupByCol()
|
public void TestGroupByCol()
|
||||||
{
|
{
|
||||||
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
IDynamicSelectQueryBuilder cmd = new DynamicSelectQueryBuilder(Database);
|
||||||
|
|
||||||
cmd.From(x => x.dbo.Users.As(x.u))
|
cmd.From(x => x.dbo.Users.As(x.u))
|
||||||
.GroupByColumn(new DynamicColumn("u.Name"));
|
.GroupByColumn(new DynamicColumn("u.Name"));
|
||||||
|
|
||||||
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u GROUP BY u.\"Name\""), cmd.CommandText());
|
Assert.AreEqual(string.Format("SELECT * FROM \"dbo\".\"Users\" AS u GROUP BY u.\"Name\""), cmd.CommandText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,150 +1,150 @@
|
|||||||
/*
|
/*
|
||||||
* DynamORM - Dynamic Object-Relational Mapping library.
|
* DynamORM - Dynamic Object-Relational Mapping library.
|
||||||
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using DynamORM.Tests.Helpers;
|
using DynamORM.Tests.Helpers;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using NUnit.Framework;
|
||||||
|
|
||||||
namespace DynamORM.Tests.Select
|
namespace DynamORM.Tests.Select
|
||||||
{
|
{
|
||||||
/// <summary>Test typed ORM.</summary>
|
/// <summary>Test typed ORM.</summary>
|
||||||
[TestClass]
|
[TestFixture]
|
||||||
public class RenamedTypedAccessTests : TypedAccessTests<Users>
|
public class RenamedTypedAccessTests : TypedAccessTests<Users>
|
||||||
{
|
{
|
||||||
/// <summary>Test something fancy... like: <code>select "first", count("first") aggregatefield from "users" group by "first" order by 2 desc;</code>.</summary>
|
/// <summary>Test something fancy... like: <code>select "first", count("first") aggregatefield from "users" group by "first" order by 2 desc;</code>.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public override void TestTypedFancyAggregateQuery()
|
public override void TestTypedFancyAggregateQuery()
|
||||||
{
|
{
|
||||||
var v = (GetTestTable().Query(type: typeof(Users), columns: "first,first:AggregateField:count", group: "first", order: ":desc:2") as IEnumerable<dynamic>).ToList();
|
var v = (GetTestTable().Query(type: typeof(Users), columns: "first,first:AggregateField:count", group: "first", order: ":desc:2") as IEnumerable<dynamic>).ToList();
|
||||||
|
|
||||||
Assert.IsNotNull(v);
|
Assert.IsNotNull(v);
|
||||||
Assert.AreEqual(187, v.Count());
|
Assert.AreEqual(187, v.Count());
|
||||||
Assert.AreEqual(4, v.First().AggregateField);
|
Assert.AreEqual(4, v.First().AggregateField);
|
||||||
Assert.AreEqual("Logan", v.First().First);
|
Assert.AreEqual("Logan", v.First().First);
|
||||||
Assert.AreEqual(2, v.Take(10).Last().AggregateField);
|
Assert.AreEqual(2, v.Take(10).Last().AggregateField);
|
||||||
Assert.AreEqual(1, v.Take(11).Last().AggregateField);
|
Assert.AreEqual(1, v.Take(11).Last().AggregateField);
|
||||||
Assert.AreEqual(1, v.Last().AggregateField);
|
Assert.AreEqual(1, v.Last().AggregateField);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test something fancy... like: <code>select "first", count("first") aggregatefield from "users" group by "first" order by 2 desc;</code>.</summary>
|
/// <summary>Test something fancy... like: <code>select "first", count("first") aggregatefield from "users" group by "first" order by 2 desc;</code>.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public override void TestGenericFancyAggregateQuery()
|
public override void TestGenericFancyAggregateQuery()
|
||||||
{
|
{
|
||||||
var v = (GetTestTable().Query<Users>(columns: "first,first:AggregateField:count", group: "first", order: ":desc:2") as IEnumerable<dynamic>).ToList();
|
var v = (GetTestTable().Query<Users>(columns: "first,first:AggregateField:count", group: "first", order: ":desc:2") as IEnumerable<dynamic>).ToList();
|
||||||
|
|
||||||
Assert.IsNotNull(v);
|
Assert.IsNotNull(v);
|
||||||
Assert.AreEqual(187, v.Count());
|
Assert.AreEqual(187, v.Count());
|
||||||
Assert.AreEqual(4, v.First().AggregateField);
|
Assert.AreEqual(4, v.First().AggregateField);
|
||||||
Assert.AreEqual("Logan", v.First().First);
|
Assert.AreEqual("Logan", v.First().First);
|
||||||
Assert.AreEqual(2, v.Take(10).Last().AggregateField);
|
Assert.AreEqual(2, v.Take(10).Last().AggregateField);
|
||||||
Assert.AreEqual(1, v.Take(11).Last().AggregateField);
|
Assert.AreEqual(1, v.Take(11).Last().AggregateField);
|
||||||
Assert.AreEqual(1, v.Last().AggregateField);
|
Assert.AreEqual(1, v.Last().AggregateField);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test typed <c>First</c> method.</summary>
|
/// <summary>Test typed <c>First</c> method.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public override void TestTypedFirst()
|
public override void TestTypedFirst()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(1, GetTestTable().First(type: typeof(Users), columns: "id").Id);
|
Assert.AreEqual(1, GetTestTable().First(type: typeof(Users), columns: "id").Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test typed <c>Last</c> method.</summary>
|
/// <summary>Test typed <c>Last</c> method.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public override void TestTypedLast()
|
public override void TestTypedLast()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(200, GetTestTable().Last(type: typeof(Users), columns: "id").Id);
|
Assert.AreEqual(200, GetTestTable().Last(type: typeof(Users), columns: "id").Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test typed <c>Single</c> multi.</summary>
|
/// <summary>Test typed <c>Single</c> multi.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public override void TestTypedSingleObject()
|
public override void TestTypedSingleObject()
|
||||||
{
|
{
|
||||||
var exp = new { id = 19, first = "Ori", last = "Ellis" };
|
var exp = new { id = 19, first = "Ori", last = "Ellis" };
|
||||||
var o = GetTestTable().Single(type: typeof(Users), columns: "id,first,last", id: 19);
|
var o = GetTestTable().Single(type: typeof(Users), columns: "id,first,last", id: 19);
|
||||||
|
|
||||||
Assert.AreEqual(exp.id, o.Id);
|
Assert.AreEqual(exp.id, o.Id);
|
||||||
Assert.AreEqual(exp.first, o.First);
|
Assert.AreEqual(exp.first, o.First);
|
||||||
Assert.AreEqual(exp.last, o.Last);
|
Assert.AreEqual(exp.last, o.Last);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test typed where expression equal.</summary>
|
/// <summary>Test typed where expression equal.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public override void TestTypedWhereEq()
|
public override void TestTypedWhereEq()
|
||||||
{
|
{
|
||||||
Assert.AreEqual("hoyt.tran", GetTestTable().Single(type: typeof(Users), where: new DynamicColumn("id").Eq(100)).Login);
|
Assert.AreEqual("hoyt.tran", GetTestTable().Single(type: typeof(Users), where: new DynamicColumn("id").Eq(100)).Login);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test typed where expression like.</summary>
|
/// <summary>Test typed where expression like.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public override void TestTypedWhereLike()
|
public override void TestTypedWhereLike()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(100, GetTestTable().Single(type: typeof(Users), where: new DynamicColumn("login").Like("Hoyt.%")).Id);
|
Assert.AreEqual(100, GetTestTable().Single(type: typeof(Users), where: new DynamicColumn("login").Like("Hoyt.%")).Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test generic <c>First</c> method.</summary>
|
/// <summary>Test generic <c>First</c> method.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public override void TestGenericFirst()
|
public override void TestGenericFirst()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(1, GetTestTable().First<Users>(columns: "id").Id);
|
Assert.AreEqual(1, GetTestTable().First<Users>(columns: "id").Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test generic <c>Last</c> method.</summary>
|
/// <summary>Test generic <c>Last</c> method.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public override void TestGenericLast()
|
public override void TestGenericLast()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(200, GetTestTable().Last<Users>(columns: "id").Id);
|
Assert.AreEqual(200, GetTestTable().Last<Users>(columns: "id").Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test generic <c>Single</c> multi.</summary>
|
/// <summary>Test generic <c>Single</c> multi.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public override void TestGenericSingleObject()
|
public override void TestGenericSingleObject()
|
||||||
{
|
{
|
||||||
var exp = new { id = 19, first = "Ori", last = "Ellis" };
|
var exp = new { id = 19, first = "Ori", last = "Ellis" };
|
||||||
var o = GetTestTable().Single<Users>(columns: "id,first,last", id: 19);
|
var o = GetTestTable().Single<Users>(columns: "id,first,last", id: 19);
|
||||||
|
|
||||||
Assert.AreEqual(exp.id, o.Id);
|
Assert.AreEqual(exp.id, o.Id);
|
||||||
Assert.AreEqual(exp.first, o.First);
|
Assert.AreEqual(exp.first, o.First);
|
||||||
Assert.AreEqual(exp.last, o.Last);
|
Assert.AreEqual(exp.last, o.Last);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test generic where expression equal.</summary>
|
/// <summary>Test generic where expression equal.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public override void TestGenericWhereEq()
|
public override void TestGenericWhereEq()
|
||||||
{
|
{
|
||||||
Assert.AreEqual("hoyt.tran", GetTestTable().Single<Users>(where: new DynamicColumn("id").Eq(100)).Login);
|
Assert.AreEqual("hoyt.tran", GetTestTable().Single<Users>(where: new DynamicColumn("id").Eq(100)).Login);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test generic where expression like.</summary>
|
/// <summary>Test generic where expression like.</summary>
|
||||||
[TestMethod]
|
[Test]
|
||||||
public override void TestGenericWhereLike()
|
public override void TestGenericWhereLike()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(100, GetTestTable().Single<Users>(where: new DynamicColumn("login").Like("Hoyt.%")).Id);
|
Assert.AreEqual(100, GetTestTable().Single<Users>(where: new DynamicColumn("login").Like("Hoyt.%")).Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
47
DynamORM.sln
47
DynamORM.sln
@@ -7,10 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DynamORM", "DynamORM\DynamO
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynamORM.Tests", "DynamORM.Tests\DynamORM.Tests.csproj", "{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynamORM.Tests", "DynamORM.Tests\DynamORM.Tests.csproj", "{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AmalgamationTool", "AmalgamationTool\AmalgamationTool.csproj", "{A64D2052-D0CD-488E-BF05-E5952615D926}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AmalgamationTool", "AmalgamationTool\AmalgamationTool.csproj", "{A64D2052-D0CD-488E-BF05-E5952615D926}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tester", "Tester\Tester.csproj", "{F747AA57-BEA7-4FB8-B371-546296789AEF}"
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -41,29 +39,18 @@ Global
|
|||||||
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Release|x86.ActiveCfg = Release|Any CPU
|
{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{A64D2052-D0CD-488E-BF05-E5952615D926}.Debug|Any CPU.ActiveCfg = Debug|x86
|
{A64D2052-D0CD-488E-BF05-E5952615D926}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{A64D2052-D0CD-488E-BF05-E5952615D926}.Debug|Any CPU.Build.0 = Debug|x86
|
{A64D2052-D0CD-488E-BF05-E5952615D926}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{A64D2052-D0CD-488E-BF05-E5952615D926}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
{A64D2052-D0CD-488E-BF05-E5952615D926}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||||
{A64D2052-D0CD-488E-BF05-E5952615D926}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
{A64D2052-D0CD-488E-BF05-E5952615D926}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||||
{A64D2052-D0CD-488E-BF05-E5952615D926}.Debug|x86.ActiveCfg = Debug|x86
|
{A64D2052-D0CD-488E-BF05-E5952615D926}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
{A64D2052-D0CD-488E-BF05-E5952615D926}.Debug|x86.Build.0 = Debug|x86
|
{A64D2052-D0CD-488E-BF05-E5952615D926}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
{A64D2052-D0CD-488E-BF05-E5952615D926}.Release|Any CPU.ActiveCfg = Release|x86
|
{A64D2052-D0CD-488E-BF05-E5952615D926}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{A64D2052-D0CD-488E-BF05-E5952615D926}.Release|Any CPU.Build.0 = Release|x86
|
{A64D2052-D0CD-488E-BF05-E5952615D926}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{A64D2052-D0CD-488E-BF05-E5952615D926}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
{A64D2052-D0CD-488E-BF05-E5952615D926}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
{A64D2052-D0CD-488E-BF05-E5952615D926}.Release|Mixed Platforms.Build.0 = Release|x86
|
{A64D2052-D0CD-488E-BF05-E5952615D926}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
{A64D2052-D0CD-488E-BF05-E5952615D926}.Release|x86.ActiveCfg = Release|x86
|
{A64D2052-D0CD-488E-BF05-E5952615D926}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{A64D2052-D0CD-488E-BF05-E5952615D926}.Release|x86.Build.0 = Release|x86
|
{A64D2052-D0CD-488E-BF05-E5952615D926}.Release|x86.Build.0 = Release|Any CPU
|
||||||
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
|
||||||
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
|
||||||
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Debug|x86.ActiveCfg = Debug|x86
|
|
||||||
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Debug|x86.Build.0 = Debug|x86
|
|
||||||
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Release|Any CPU.ActiveCfg = Release|x86
|
|
||||||
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
|
||||||
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
|
||||||
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Release|x86.ActiveCfg = Release|x86
|
|
||||||
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Release|x86.Build.0 = Release|x86
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -72,6 +59,6 @@ Global
|
|||||||
SolutionGuid = {22781EB3-2148-4CA4-845A-B55265A7B5C2}
|
SolutionGuid = {22781EB3-2148-4CA4-845A-B55265A7B5C2}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(MonoDevelopProperties) = preSolution
|
GlobalSection(MonoDevelopProperties) = preSolution
|
||||||
StartupItem = Tester\Tester.csproj
|
StartupItem = DynamORM.Tests\DynamORM.Tests.csproj
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net472;net6.0;net8.0;net10.0</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net472;net6.0;net8.0;net10.0</TargetFrameworks>
|
||||||
<Description>Dynamic Object-Relational Mapping library.</Description>
|
<Description>Dynamic Object-Relational Mapping library.</Description>
|
||||||
<Copyright>Copyright © RUSSEK Software 2012-2026</Copyright>
|
<Copyright>Copyright © RUSSEK Software 2012-2026</Copyright>
|
||||||
<Company>RUSSEK Software</Company>
|
<Company>RUSSEK Software</Company>
|
||||||
@@ -10,8 +10,14 @@
|
|||||||
<RepositoryUrl>https://git.dr4cul4.pl/RUSSEK-Software/DynamORM</RepositoryUrl>
|
<RepositoryUrl>https://git.dr4cul4.pl/RUSSEK-Software/DynamORM</RepositoryUrl>
|
||||||
<PackageProjectUrl>https://dr4cul4.pl</PackageProjectUrl>
|
<PackageProjectUrl>https://dr4cul4.pl</PackageProjectUrl>
|
||||||
<Product>DynamORM</Product>
|
<Product>DynamORM</Product>
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<GenerateAmalgamationOnBuild>true</GenerateAmalgamationOnBuild>
|
||||||
|
<AmalgamationSourceDir>$(MSBuildProjectDirectory)</AmalgamationSourceDir>
|
||||||
|
<AmalgamationOutputFile>$(MSBuildProjectDirectory)\..\AmalgamationTool\DynamORM.Amalgamation.cs</AmalgamationOutputFile>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<IncludeSymbols>true</IncludeSymbols>
|
<IncludeSymbols>true</IncludeSymbols>
|
||||||
@@ -22,7 +28,14 @@
|
|||||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||||
<PackageReference Include="System.Data.Common" Version="4.3.0" />
|
<PackageReference Include="System.Data.Common" Version="4.3.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Condition="$(TargetFramework.StartsWith('net4')) AND '$(MSBuildRuntimeType)' == 'Core' AND '$(OS)' != 'Windows_NT'">
|
<ItemGroup Condition="$(TargetFramework.StartsWith('net4')) AND '$(MSBuildRuntimeType)' == 'Core' AND '$(OS)' != 'Windows_NT'">
|
||||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" />
|
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
|
||||||
|
<Target Name="GenerateAmalgamation"
|
||||||
|
AfterTargets="Build"
|
||||||
|
Condition="'$(GenerateAmalgamationOnBuild)' == 'true' and '$(TargetFramework)' == 'net10.0' and '$(IsCrossTargetingBuild)' != 'true'">
|
||||||
|
<Message Importance="high" Text="Generating amalgamation file to $(AmalgamationOutputFile)" />
|
||||||
|
<Exec Command="dotnet run --project "$(MSBuildProjectDirectory)\..\AmalgamationTool\AmalgamationTool.csproj" -- "$(AmalgamationSourceDir)" "$(AmalgamationOutputFile)"" />
|
||||||
|
</Target>
|
||||||
|
</Project>
|
||||||
|
|||||||
@@ -22,3 +22,4 @@ Full documentation is available in [`docs/README.md`](docs/README.md):
|
|||||||
- `DynamORM.Tests/`: test suite
|
- `DynamORM.Tests/`: test suite
|
||||||
- `AmalgamationTool/`: amalgamation generator and generated single-file output
|
- `AmalgamationTool/`: amalgamation generator and generated single-file output
|
||||||
- `DynamORM.Net40.csproj`: net40 build for amalgamated source compatibility
|
- `DynamORM.Net40.csproj`: net40 build for amalgamated source compatibility
|
||||||
|
- `scripts/docker/`: dockerized build, test, amalgamation generation, and mono net40 smoke scripts
|
||||||
|
|||||||
@@ -1,169 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data;
|
|
||||||
using System.Linq;
|
|
||||||
using DynamORM;
|
|
||||||
using DynamORM.Helpers;
|
|
||||||
using DynamORM.Mapper;
|
|
||||||
using Tester.RealTests;
|
|
||||||
|
|
||||||
namespace Tester
|
|
||||||
{
|
|
||||||
internal class Program
|
|
||||||
{
|
|
||||||
private static DynamicDatabase GetORM()
|
|
||||||
{
|
|
||||||
return new DynamicDatabase(System.Data.SqlClient.SqlClientFactory.Instance,
|
|
||||||
//"packet size=4096;User Id=sa;Password=sWe7PepR;data source=192.168.22.10;initial catalog=PLAYGROUND;",
|
|
||||||
"packet size=4096;User Id=sa;Password=sWe7PepR;data source=192.168.22.10;initial catalog=MOM_DEMO_WMS_FILLED;",
|
|
||||||
DynamicDatabaseOptions.SingleConnection | DynamicDatabaseOptions.SingleTransaction | DynamicDatabaseOptions.SupportSchema |
|
|
||||||
DynamicDatabaseOptions.SupportStoredProcedures | DynamicDatabaseOptions.SupportTop | DynamicDatabaseOptions.DumpCommands |
|
|
||||||
DynamicDatabaseOptions.SupportStoredProceduresResult);
|
|
||||||
|
|
||||||
////return new DynamORM.DynamicDatabase(System.Data.SQLite.SQLiteFactory.Instance,
|
|
||||||
//// "Data Source=test.db3;",
|
|
||||||
//// DynamORM.DynamicDatabaseOptions.SingleConnection | DynamORM.DynamicDatabaseOptions.SingleTransaction |
|
|
||||||
//// DynamORM.DynamicDatabaseOptions.SupportSchema | DynamORM.DynamicDatabaseOptions.SupportLimitOffset);
|
|
||||||
///
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void Main(string[] args)
|
|
||||||
{
|
|
||||||
|
|
||||||
using (var db = GetORM())
|
|
||||||
{
|
|
||||||
var num = db.Procedures.usp_NewNumber(counterName: "TRAY");
|
|
||||||
|
|
||||||
//ProcedureHell(db);
|
|
||||||
//OddNullabeleProblem.Test(db);
|
|
||||||
|
|
||||||
//TableFun(db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void TableFun(DynamicDatabase db)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
db.Execute("DROP TABLE Experiments ");
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
|
|
||||||
db.Execute(@"CREATE TABLE Experiments (
|
|
||||||
id int NOT NULL PRIMARY KEY,
|
|
||||||
t1 nvarchar(50) NOT NULL DEFAULT N'',
|
|
||||||
t2 varchar(50) NOT NULL DEFAULT '',
|
|
||||||
dd date,
|
|
||||||
tt time);");
|
|
||||||
|
|
||||||
db.Insert<Ex>().Insert(new Ex
|
|
||||||
{
|
|
||||||
id = 1,
|
|
||||||
t1 = "T1",
|
|
||||||
t2 = "T1",
|
|
||||||
dd = DateTime.Now,
|
|
||||||
tt = TimeSpan.FromDays(2) + TimeSpan.FromHours(10),
|
|
||||||
}).Execute();
|
|
||||||
|
|
||||||
var tt = db.From<Ex>().Where(x => x.id == 1).ToList<Ex>().FirstOrDefault();
|
|
||||||
|
|
||||||
db.Update<Ex>().Where(x => x.id == 1).Set(x => x.tt = TimeSpan.FromMinutes(10), x => x.dd = DateTime.Now.AddDays(2)).Execute();
|
|
||||||
|
|
||||||
db.Execute("DROP TABLE Experiments ");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Table(Name = "Experiments")]
|
|
||||||
private class Ex
|
|
||||||
{
|
|
||||||
public int id { get; set; }
|
|
||||||
public string t1 { get; set; }
|
|
||||||
public string t2 { get; set; }
|
|
||||||
public DateTime dd { get; set; }
|
|
||||||
public TimeSpan tt { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ProcedureHell(DynamicDatabase db)
|
|
||||||
{
|
|
||||||
db.Execute(@"CREATE OR ALTER PROCEDURE sp_Exp_Scalar AS SELECT 42;");
|
|
||||||
var res0 = db.Procedures.sp_Exp_Scalar();
|
|
||||||
var res1 = db.Procedures.sp_Exp_Scalar<int>();
|
|
||||||
|
|
||||||
db.Execute(@"CREATE OR ALTER PROCEDURE sp_Exp_ReturnInt AS RETURN 42;");
|
|
||||||
var res2 = db.Procedures.sp_Exp_ReturnInt();
|
|
||||||
|
|
||||||
db.Execute(@"CREATE OR ALTER PROCEDURE sp_Exp_SomeData AS
|
|
||||||
SELECT 1 Id, 'Some Name 1' [Name], 'Some Desc 1' [Desc], GETDATE() [Date]
|
|
||||||
UNION ALL SELECT 2 Id, 'Some Name 2', 'Some Desc 2', GETDATE() [Date];");
|
|
||||||
var res3 = db.Procedures.sp_Exp_SomeData<sp_Exp_SomeData_Result>();
|
|
||||||
var res4 = db.Procedures.sp_Exp_SomeData<List<sp_Exp_SomeData_Result>>();
|
|
||||||
|
|
||||||
db.Execute(@"CREATE OR ALTER PROCEDURE sp_Exp_SomeInputAndOutput
|
|
||||||
@Name nvarchar(50),
|
|
||||||
@Result nvarchar(256) OUTPUT
|
|
||||||
AS
|
|
||||||
SELECT @Result = 'Hi, ' + @Name + ' your lucky number is 42!';");
|
|
||||||
var res5 = db.Procedures.sp_Exp_SomeInputAndOutput<string, sp_Exp_SomeInputAndOutput_Result>(Name: "G4g4r1n", out_Result: new DynamicColumn
|
|
||||||
{
|
|
||||||
Schema = new DynamicSchemaColumn
|
|
||||||
{
|
|
||||||
Size = 256,
|
|
||||||
},
|
|
||||||
}, ret_Return: 0);
|
|
||||||
var res6 = db.Procedures.sp_Exp_SomeInputAndOutput<string, sp_Exp_SomeInputAndOutput_Result>(Name: "G4g4r1n", out_Result: new DynamicSchemaColumn
|
|
||||||
{
|
|
||||||
Size = 256,
|
|
||||||
}, ret_Return: 0);
|
|
||||||
|
|
||||||
db.Execute(@"CREATE OR ALTER PROCEDURE sp_Exp_SomeInputAndOutputWithDataAndReturn
|
|
||||||
@Name nvarchar(50),
|
|
||||||
@Result nvarchar(256) OUTPUT
|
|
||||||
AS
|
|
||||||
SELECT @Result = 'Hi, ' + @Name + ' your lucky number is 42!'
|
|
||||||
|
|
||||||
SELECT 1 Id, 'Some Name 1' [Name], 'Some Desc 1' [Desc], GETDATE() [Date]
|
|
||||||
UNION ALL SELECT 2 Id, 'Some Name 2', 'Some Desc 2', GETDATE() [Date]
|
|
||||||
|
|
||||||
RETURN 42;");
|
|
||||||
var res7 = db.Procedures.sp_Exp_SomeInputAndOutputWithDataAndReturn<List<sp_Exp_SomeInputAndOutputWithDataAndReturn_Result.Data>, sp_Exp_SomeInputAndOutputWithDataAndReturn_Result>(Name: "G4g4r1n", out_Result: new DynamicColumn
|
|
||||||
{
|
|
||||||
Schema = new DynamicSchemaColumn
|
|
||||||
{
|
|
||||||
Size = 256,
|
|
||||||
},
|
|
||||||
}, ret_Return: 0);
|
|
||||||
var res8 = db.Procedures.sp_Exp_SomeInputAndOutputWithDataAndReturn<List<sp_Exp_SomeInputAndOutputWithDataAndReturn_Result.Data>, sp_Exp_SomeInputAndOutputWithDataAndReturn_Result>(Name: "G4g4r1n", out_Result: new DynamicSchemaColumn
|
|
||||||
{
|
|
||||||
Size = 256,
|
|
||||||
}, ret_Return: 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class sp_Exp_SomeData_Result
|
|
||||||
{
|
|
||||||
public virtual int Id { get; set; }
|
|
||||||
public virtual string Name { get; set; }
|
|
||||||
public virtual string Desc { get; set; }
|
|
||||||
public virtual DateTime Date { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private class sp_Exp_SomeInputAndOutput_Result
|
|
||||||
{
|
|
||||||
public virtual string Result { get; set; }
|
|
||||||
public virtual string Return { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private class sp_Exp_SomeInputAndOutputWithDataAndReturn_Result
|
|
||||||
{
|
|
||||||
public class Data
|
|
||||||
{
|
|
||||||
public virtual int Id { get; set; }
|
|
||||||
public virtual string Name { get; set; }
|
|
||||||
public virtual string Desc { get; set; }
|
|
||||||
public virtual DateTime Date { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual List<Data> sp_Exp_SomeInputAndOutputWithDataAndReturn { get; set; }
|
|
||||||
public virtual string Result { get; set; }
|
|
||||||
public virtual string Return { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,448 +0,0 @@
|
|||||||
using DynamORM;
|
|
||||||
using DynamORM.Mapper;
|
|
||||||
using DynamORM.Objects;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Tester.RealTests
|
|
||||||
{
|
|
||||||
internal static class OddNullabeleProblem
|
|
||||||
{
|
|
||||||
public static void Test(DynamicDatabase db)
|
|
||||||
{
|
|
||||||
var ca = new mom_Contractors_Articles();
|
|
||||||
ca.mca_min_date_valid_out = 5;
|
|
||||||
ca.mca_mar_code = "342";
|
|
||||||
ca.mca_mar_name = "234";
|
|
||||||
ca.SetDynamicEntityState(DynamicEntityState.Existing);
|
|
||||||
ca.mca_min_date_valid_out = null;
|
|
||||||
ca.mca_mar_code = null;
|
|
||||||
ca.mca_mar_name = null;
|
|
||||||
|
|
||||||
var r = new DynamicRepositoryBase<mom_Contractors_Articles>(db);
|
|
||||||
r.Save(ca);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Table(Name = "mom_Contractors_Articles")]
|
|
||||||
public class mom_Contractors_Articles : DynamicEntityBase
|
|
||||||
{
|
|
||||||
private System.Guid _mca_id;
|
|
||||||
|
|
||||||
[Column("mca_id", true, AllowNull = false)]
|
|
||||||
public virtual System.Guid mca_id
|
|
||||||
{
|
|
||||||
get { return _mca_id; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_id != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_id", _mca_id, value);
|
|
||||||
_mca_id = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.Nullable<System.Guid> _mca_mc_id;
|
|
||||||
|
|
||||||
[Column("mca_mc_id")]
|
|
||||||
public virtual System.Nullable<System.Guid> mca_mc_id
|
|
||||||
{
|
|
||||||
get { return _mca_mc_id; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_mc_id != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_mc_id", _mca_mc_id, value);
|
|
||||||
_mca_mc_id = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.Nullable<System.Guid> _mca_mar_id;
|
|
||||||
|
|
||||||
[Column("mca_mar_id")]
|
|
||||||
public virtual System.Nullable<System.Guid> mca_mar_id
|
|
||||||
{
|
|
||||||
get { return _mca_mar_id; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_mar_id != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_mar_id", _mca_mar_id, value);
|
|
||||||
_mca_mar_id = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.Nullable<System.Int32> _mca_min_date_valid_out;
|
|
||||||
|
|
||||||
[Column("mca_min_date_valid_out", AllowNull = true)]
|
|
||||||
public virtual System.Nullable<System.Int32> mca_min_date_valid_out
|
|
||||||
{
|
|
||||||
get { return _mca_min_date_valid_out; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_min_date_valid_out != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_min_date_valid_out", _mca_min_date_valid_out, value);
|
|
||||||
_mca_min_date_valid_out = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.Nullable<System.Int32> _mca_min_date_valid_in;
|
|
||||||
|
|
||||||
[Column("mca_min_date_valid_in")]
|
|
||||||
public virtual System.Nullable<System.Int32> mca_min_date_valid_in
|
|
||||||
{
|
|
||||||
get { return _mca_min_date_valid_in; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_min_date_valid_in != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_min_date_valid_in", _mca_min_date_valid_in, value);
|
|
||||||
_mca_min_date_valid_in = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.String _mca_mar_code;
|
|
||||||
|
|
||||||
[Column("mca_mar_code", AllowNull = true)]
|
|
||||||
public virtual System.String mca_mar_code
|
|
||||||
{
|
|
||||||
get { return _mca_mar_code; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_mar_code != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_mar_code", _mca_mar_code, value);
|
|
||||||
_mca_mar_code = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.String _mca_mar_name;
|
|
||||||
|
|
||||||
[Column("mca_mar_name", AllowNull = true)]
|
|
||||||
public virtual System.String mca_mar_name
|
|
||||||
{
|
|
||||||
get { return _mca_mar_name; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_mar_name != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_mar_name", _mca_mar_name, value);
|
|
||||||
_mca_mar_name = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.String _mca_gid;
|
|
||||||
|
|
||||||
[Column("mca_GID")]
|
|
||||||
public virtual System.String mca_GID
|
|
||||||
{
|
|
||||||
get { return _mca_gid; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_gid != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_GID", _mca_gid, value);
|
|
||||||
_mca_gid = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.Nullable<System.Decimal> _mca_percent_wz;
|
|
||||||
|
|
||||||
[Column("mca_percent_WZ")]
|
|
||||||
public virtual System.Nullable<System.Decimal> mca_percent_WZ
|
|
||||||
{
|
|
||||||
get { return _mca_percent_wz; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_percent_wz != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_percent_WZ", _mca_percent_wz, value);
|
|
||||||
_mca_percent_wz = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.Nullable<System.Decimal> _mca_percent_pz;
|
|
||||||
|
|
||||||
[Column("mca_percent_PZ")]
|
|
||||||
public virtual System.Nullable<System.Decimal> mca_percent_PZ
|
|
||||||
{
|
|
||||||
get { return _mca_percent_pz; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_percent_pz != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_percent_PZ", _mca_percent_pz, value);
|
|
||||||
_mca_percent_pz = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.Byte _mca_tss_ignore;
|
|
||||||
|
|
||||||
[Column("mca_tss_ignore", AllowNull = false)]
|
|
||||||
public virtual System.Byte mca_tss_ignore
|
|
||||||
{
|
|
||||||
get { return _mca_tss_ignore; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_tss_ignore != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_tss_ignore", _mca_tss_ignore, value);
|
|
||||||
_mca_tss_ignore = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.String _mca_mar_bar_code;
|
|
||||||
|
|
||||||
[Column("mca_mar_bar_code")]
|
|
||||||
public virtual System.String mca_mar_bar_code
|
|
||||||
{
|
|
||||||
get { return _mca_mar_bar_code; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_mar_bar_code != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_mar_bar_code", _mca_mar_bar_code, value);
|
|
||||||
_mca_mar_bar_code = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.Nullable<System.Guid> _mca_mus_id_modified;
|
|
||||||
|
|
||||||
[Column("mca_mus_id_modified")]
|
|
||||||
public virtual System.Nullable<System.Guid> mca_mus_id_modified
|
|
||||||
{
|
|
||||||
get { return _mca_mus_id_modified; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_mus_id_modified != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_mus_id_modified", _mca_mus_id_modified, value);
|
|
||||||
_mca_mus_id_modified = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.Nullable<System.DateTime> _mca_date_modified;
|
|
||||||
|
|
||||||
[Column("mca_date_modified")]
|
|
||||||
public virtual System.Nullable<System.DateTime> mca_date_modified
|
|
||||||
{
|
|
||||||
get { return _mca_date_modified; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_date_modified != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_date_modified", _mca_date_modified, value);
|
|
||||||
_mca_date_modified = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.String _mca_ean_label_unit;
|
|
||||||
|
|
||||||
[Column("mca_ean_label_unit")]
|
|
||||||
public virtual System.String mca_ean_label_unit
|
|
||||||
{
|
|
||||||
get { return _mca_ean_label_unit; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_ean_label_unit != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_ean_label_unit", _mca_ean_label_unit, value);
|
|
||||||
_mca_ean_label_unit = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.String _mca_ean_label_pckg;
|
|
||||||
|
|
||||||
[Column("mca_ean_label_pckg")]
|
|
||||||
public virtual System.String mca_ean_label_pckg
|
|
||||||
{
|
|
||||||
get { return _mca_ean_label_pckg; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_ean_label_pckg != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_ean_label_pckg", _mca_ean_label_pckg, value);
|
|
||||||
_mca_ean_label_pckg = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.Nullable<System.Decimal> _mca_price;
|
|
||||||
|
|
||||||
[Column("mca_price")]
|
|
||||||
public virtual System.Nullable<System.Decimal> mca_price
|
|
||||||
{
|
|
||||||
get { return _mca_price; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_price != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_price", _mca_price, value);
|
|
||||||
_mca_price = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.String _mca_currency_code;
|
|
||||||
|
|
||||||
[Column("mca_currency_code")]
|
|
||||||
public virtual System.String mca_currency_code
|
|
||||||
{
|
|
||||||
get { return _mca_currency_code; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_currency_code != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_currency_code", _mca_currency_code, value);
|
|
||||||
_mca_currency_code = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.Nullable<System.Int32> _mca_time_ahead;
|
|
||||||
|
|
||||||
[Column("mca_time_ahead")]
|
|
||||||
public virtual System.Nullable<System.Int32> mca_time_ahead
|
|
||||||
{
|
|
||||||
get { return _mca_time_ahead; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_time_ahead != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_time_ahead", _mca_time_ahead, value);
|
|
||||||
_mca_time_ahead = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.Nullable<System.Decimal> _mca_last_price;
|
|
||||||
|
|
||||||
[Column("mca_last_price")]
|
|
||||||
public virtual System.Nullable<System.Decimal> mca_last_price
|
|
||||||
{
|
|
||||||
get { return _mca_last_price; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_last_price != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_last_price", _mca_last_price, value);
|
|
||||||
_mca_last_price = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.Nullable<System.Decimal> _mca_logistic_minimum_value;
|
|
||||||
|
|
||||||
[Column("mca_logistic_minimum_value")]
|
|
||||||
public virtual System.Nullable<System.Decimal> mca_logistic_minimum_value
|
|
||||||
{
|
|
||||||
get { return _mca_logistic_minimum_value; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_logistic_minimum_value != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_logistic_minimum_value", _mca_logistic_minimum_value, value);
|
|
||||||
_mca_logistic_minimum_value = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.Nullable<System.Decimal> _mca_logistic_minimum_mplt;
|
|
||||||
|
|
||||||
[Column("mca_logistic_minimum_mplt")]
|
|
||||||
public virtual System.Nullable<System.Decimal> mca_logistic_minimum_mplt
|
|
||||||
{
|
|
||||||
get { return _mca_logistic_minimum_mplt; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_logistic_minimum_mplt != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_logistic_minimum_mplt", _mca_logistic_minimum_mplt, value);
|
|
||||||
_mca_logistic_minimum_mplt = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.Nullable<System.Decimal> _mca_logistic_minimum_qty;
|
|
||||||
|
|
||||||
[Column("mca_logistic_minimum_qty")]
|
|
||||||
public virtual System.Nullable<System.Decimal> mca_logistic_minimum_qty
|
|
||||||
{
|
|
||||||
get { return _mca_logistic_minimum_qty; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_logistic_minimum_qty != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_logistic_minimum_qty", _mca_logistic_minimum_qty, value);
|
|
||||||
_mca_logistic_minimum_qty = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.Nullable<System.Decimal> _mca_req_kj_percent;
|
|
||||||
|
|
||||||
[Column("mca_req_kj_percent")]
|
|
||||||
public virtual System.Nullable<System.Decimal> mca_req_kj_percent
|
|
||||||
{
|
|
||||||
get { return _mca_req_kj_percent; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_req_kj_percent != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_req_kj_percent", _mca_req_kj_percent, value);
|
|
||||||
_mca_req_kj_percent = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.Nullable<System.Decimal> _mca_min_order_qty;
|
|
||||||
|
|
||||||
[Column("mca_min_order_qty")]
|
|
||||||
public virtual System.Nullable<System.Decimal> mca_min_order_qty
|
|
||||||
{
|
|
||||||
get { return _mca_min_order_qty; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_min_order_qty != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_min_order_qty", _mca_min_order_qty, value);
|
|
||||||
_mca_min_order_qty = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.Byte _mca_default_contractor;
|
|
||||||
|
|
||||||
[Column("mca_default_contractor", AllowNull = false)]
|
|
||||||
public virtual System.Byte mca_default_contractor
|
|
||||||
{
|
|
||||||
get { return _mca_default_contractor; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_mca_default_contractor != value)
|
|
||||||
{
|
|
||||||
this.OnPropertyChanging("mca_default_contractor", _mca_default_contractor, value);
|
|
||||||
_mca_default_contractor = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
|
||||||
<Copyright>Copyright © RUSSEK Software 2012-2022</Copyright>
|
|
||||||
<Company>RUSSEK Software</Company>
|
|
||||||
<Authors>Grzegorz Russek</Authors>
|
|
||||||
<VersionPrefix>1.2.1</VersionPrefix>
|
|
||||||
<RepositoryUrl>https://svn.dr4cul4.pl/svn/DynamORM/</RepositoryUrl>
|
|
||||||
<PackageProjectUrl>https://dr4cul4.pl</PackageProjectUrl>
|
|
||||||
<Product>DynamORM</Product>
|
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
|
||||||
<PackageReference Include="System.Data.Common" Version="4.3.0" />
|
|
||||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup Condition="$(TargetFramework.StartsWith('net4')) AND '$(MSBuildRuntimeType)' == 'Core' AND '$(OS)' != 'Windows_NT'">
|
|
||||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\DynamORM\DynamORM.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Properties\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
19
scripts/docker/build-and-test.sh
Executable file
19
scripts/docker/build-and-test.sh
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||||
|
IMAGE="${DOTNET_IMAGE:-mcr.microsoft.com/dotnet/sdk:10.0}"
|
||||||
|
|
||||||
|
docker run --rm \
|
||||||
|
-v "${ROOT_DIR}:/workspace" \
|
||||||
|
-w /workspace \
|
||||||
|
"${IMAGE}" \
|
||||||
|
bash -lc "
|
||||||
|
set -euo pipefail
|
||||||
|
dotnet --info
|
||||||
|
dotnet restore DynamORM.sln
|
||||||
|
dotnet build DynamORM.sln -c Release --no-restore
|
||||||
|
dotnet test DynamORM.Tests/DynamORM.Tests.csproj -c Release --no-build
|
||||||
|
dotnet pack DynamORM/DynamORM.csproj -c Release --no-build -o /workspace/artifacts/nuget
|
||||||
|
"
|
||||||
|
|
||||||
11
scripts/docker/ci-local.sh
Executable file
11
scripts/docker/ci-local.sh
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||||
|
|
||||||
|
"${ROOT_DIR}/scripts/docker/generate-amalgamation.sh"
|
||||||
|
"${ROOT_DIR}/scripts/docker/build-and-test.sh"
|
||||||
|
"${ROOT_DIR}/scripts/docker/mono-net40-smoke.sh"
|
||||||
|
|
||||||
|
echo "All docker checks completed."
|
||||||
|
|
||||||
15
scripts/docker/generate-amalgamation.sh
Executable file
15
scripts/docker/generate-amalgamation.sh
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||||
|
IMAGE="${DOTNET_IMAGE:-mcr.microsoft.com/dotnet/sdk:10.0}"
|
||||||
|
|
||||||
|
docker run --rm \
|
||||||
|
-v "${ROOT_DIR}:/workspace" \
|
||||||
|
-w /workspace \
|
||||||
|
"${IMAGE}" \
|
||||||
|
bash -lc "
|
||||||
|
set -euo pipefail
|
||||||
|
dotnet run --project AmalgamationTool/AmalgamationTool.csproj -- DynamORM AmalgamationTool/DynamORM.Amalgamation.cs
|
||||||
|
"
|
||||||
|
|
||||||
23
scripts/docker/mono-net40-smoke.sh
Executable file
23
scripts/docker/mono-net40-smoke.sh
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||||
|
IMAGE="${MONO_IMAGE:-mono:6.12}"
|
||||||
|
|
||||||
|
docker run --rm \
|
||||||
|
-v "${ROOT_DIR}:/workspace" \
|
||||||
|
-w /workspace \
|
||||||
|
"${IMAGE}" \
|
||||||
|
bash -lc "
|
||||||
|
set -euo pipefail
|
||||||
|
mono --version
|
||||||
|
mcs -langversion:latest -target:library -sdk:4 \
|
||||||
|
-r:System \
|
||||||
|
-r:System.Core \
|
||||||
|
-r:System.Data \
|
||||||
|
-r:Microsoft.CSharp \
|
||||||
|
-out:/tmp/DynamORM.Net40.Smoke.dll \
|
||||||
|
AmalgamationTool/DynamORM.Amalgamation.cs
|
||||||
|
ls -lh /tmp/DynamORM.Net40.Smoke.dll
|
||||||
|
"
|
||||||
|
|
||||||
Reference in New Issue
Block a user