Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persistent dictionary prototype #496

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Tortuga.Chain/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## Version 4.4


### Features


### Bugs


### Technical Debt


[#497 Update interfaces to expose more functionality](https://github.com/TortugaResearch/Tortuga.Chain/issues/497)

`ICrudDataSource` and `IScalarDbCommandBuilder` were updated to expose more functionality from their matching classes.

## Version 4.3

Updated dependency to Anchor 4.1.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ class SupportsSqlQueriesTrait<TCommand, TParameter> : ISupportsSqlQueries
where TCommand : DbCommand
where TParameter : DbParameter
{
IMultipleTableDbCommandBuilder ISupportsSqlQueries.Sql(string sqlStatement, object argumentValue)
[Partial("sqlStatement,argumentValue")]
public Func<string, object?, MultipleTableDbCommandBuilder<TCommand, TParameter>> OnSql { get; set; } = null!;

IMultipleTableDbCommandBuilder ISupportsSqlQueries.Sql(string sqlStatement, object? argumentValue)
{
return OnSql(sqlStatement, argumentValue);
}
Expand All @@ -33,12 +36,8 @@ public MultipleTableDbCommandBuilder<TCommand, TParameter> Sql(string sqlStateme
/// <param name="argumentValue">The argument value.</param>
/// <returns>SqlServerSqlCall.</returns>
[Expose]
public MultipleTableDbCommandBuilder<TCommand, TParameter> Sql(string sqlStatement, object argumentValue)
public MultipleTableDbCommandBuilder<TCommand, TParameter> Sql(string sqlStatement, object? argumentValue)
{
return OnSql(sqlStatement, argumentValue);
}

[Partial("sqlStatement,argumentValue")]
public Func<string, object?, MultipleTableDbCommandBuilder<TCommand, TParameter>> OnSql { get; set; } = null!;
}

13 changes: 12 additions & 1 deletion Tortuga.Chain/Tortuga.Chain.Access/Access/AccessMetadataCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,26 @@ public override void Preload()
/// Quotes the name of the column.
/// </summary>
/// <param name="columnName">Name of the column.</param>
/// <exception cref="System.ArgumentException">columnName</exception>
/// <remarks>This assumes the column name wasn't already quoted.</remarks>
public override string QuoteColumnName(string columnName)
{
if (columnName == "*")
if (string.IsNullOrEmpty(columnName))
throw new ArgumentException($"{nameof(columnName)} is null or empty.", nameof(columnName));

if (columnName == "*" || columnName[0] == '[')
return columnName;

return $"[{columnName}]";
}

/// <summary>
/// Parse a string and return the database specific representation of the database object's name as a quoted string.
/// </summary>
/// <param name="name">Name of the object.</param>
/// <returns>System.String.</returns>
public override string QuoteObjectName(string name) => ParseObjectName(name).ToQuotedString();

/// <summary>
/// Resets the metadata cache, clearing out all cached metadata.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ProductName>Tortuga Chain</ProductName>
<Deterministic>true</Deterministic>

<Version>4.3.0</Version>
<Version>4.4.0</Version>

<PackageLicenseExpression>MIT</PackageLicenseExpression>

Expand Down Expand Up @@ -57,7 +57,7 @@
</ItemGroup>

<ItemGroup Condition="'$(Configuration)'=='Release'">
<PackageReference Include="Tortuga.Chain.Core.OleDb" Version="4.3.0" />
<PackageReference Include="Tortuga.Chain.Core.OleDb" Version="4.4.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ProductName>Tortuga Chain</ProductName>
<Deterministic>true</Deterministic>

<Version>4.3.0</Version>
<Version>4.4.0</Version>

<PackageLicenseExpression>MIT</PackageLicenseExpression>

Expand Down Expand Up @@ -39,7 +39,7 @@
</ItemGroup>

<ItemGroup Condition="'$(Configuration)'=='Release'">
<PackageReference Include="Tortuga.Chain.Core" Version="4.3.0" />
<PackageReference Include="Tortuga.Chain.Core" Version="4.4.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<ProductName>Tortuga Chain</ProductName>
<Deterministic>true</Deterministic>

<Version>4.3.0</Version>
<Version>4.4.0</Version>

<PackageLicenseExpression>MIT</PackageLicenseExpression>

Expand Down Expand Up @@ -52,7 +52,7 @@
</ItemGroup>

<ItemGroup Condition="'$(Configuration)'=='Release'">
<PackageReference Include="Tortuga.Chain.Core" Version="4.3.0" />
<PackageReference Include="Tortuga.Chain.Core" Version="4.4.0" />
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<ProductName>Tortuga Chain</ProductName>
<Deterministic>true</Deterministic>

<Version>4.3.0</Version>
<Version>4.4.0</Version>

<PackageLicenseExpression>MIT</PackageLicenseExpression>

Expand Down Expand Up @@ -46,7 +46,7 @@
</ItemGroup>

<ItemGroup Condition="'$(Configuration)'=='Release'">
<PackageReference Include="Tortuga.Chain.Core" Version="4.3.0" />
<PackageReference Include="Tortuga.Chain.Core" Version="4.4.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,36 @@ public interface IMultipleRowDbCommandBuilder : ISingleRowDbCommandBuilder
/// <returns></returns>
ILink<List<byte[]?>> ToByteArrayOrNullList(ListOptions listOptions = ListOptions.None);

/// <summary>
/// Indicates the results should be materialized as a list of chars.
/// </summary>
/// <param name="columnName">Name of the desired column.</param>
/// <param name="listOptions">The list options.</param>
/// <returns></returns>
ILink<List<char>> ToCharList(string columnName, ListOptions listOptions = ListOptions.None);

/// <summary>
/// Indicates the results should be materialized as a list of chars.
/// </summary>
/// <param name="listOptions">The list options.</param>
/// <returns></returns>
ILink<List<char>> ToCharList(ListOptions listOptions = ListOptions.None);

/// <summary>
/// Indicates the results should be materialized as a list of chars.
/// </summary>
/// <param name="listOptions">The list options.</param>
/// <returns>Tortuga.Chain.ILink&lt;System.Collections.Generic.List&lt;System.Char&gt;&gt;.</returns>
ILink<List<char?>> ToCharOrNullList(ListOptions listOptions = ListOptions.None);

/// <summary>
/// Indicates the results should be materialized as a list of chars.
/// </summary>
/// <param name="columnName">Name of the desired column.</param>
/// <param name="listOptions">The list options.</param>
/// <returns>Tortuga.Chain.ILink&lt;System.Collections.Generic.List&lt;System.Char&gt;&gt;.</returns>
ILink<List<char?>> ToCharOrNullList(string columnName, ListOptions listOptions = ListOptions.None);

/// <summary>
/// Materializes the result as a list of objects.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,31 @@ public interface IScalarDbCommandBuilder : IDbCommandBuilder
/// <param name="columnName">Name of the desired column.</param>
ILink<byte?> ToByteOrNull(string columnName);

/// <summary>
/// Indicates the results should be materialized as a non-nullable char.
/// </summary>
/// <returns></returns>
ILink<char> ToChar();

/// <summary>
/// Indicates the results should be materialized as a non-nullable char.
/// </summary>
/// <returns></returns>
ILink<char> ToChar(string columnName);

/// <summary>
/// Indicates the results should be materialized as a nullable char.
/// </summary>
/// <returns></returns>
/// <param name="columnName">Name of the desired column.</param>
ILink<char?> ToCharOrNull(string columnName);

/// <summary>
/// Indicates the results should be materialized as a nullable char.
/// </summary>
/// <returns></returns>
ILink<char?> ToCharOrNull();

/// <summary>
/// Indicates the results should be materialized as a DateTime.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
namespace Tortuga.Chain.DataSources;

/// <summary>
/// Used to mark data sources that support a full set of basic CRUD operations.
/// </summary>
/// <remarks>Warning: This interface is meant to simulate multiple inheritance and work-around some issues with exposing generic types. Do not implement it in client code, as new methods will be added over time.</remarks>
public interface ICrudDataSource :
IDataSource,
ISupportsSqlQueries,
ISupportsDelete,
ISupportsDeleteAll,
ISupportsDeleteByKey,
ISupportsDeleteByKeyList,
ISupportsDeleteSet,
ISupportsDeleteAll,
ISupportsFrom,
ISupportsGetByColumn,
ISupportsGetByColumnList,
ISupportsGetByKey,
ISupportsGetByKeyList,
ISupportsInsert,
ISupportsSqlQueries,
ISupportsUpdate,
ISupportsUpdateByKey,
ISupportsUpdateByKeyList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ public interface ISupportsSqlQueries
/// </summary>
/// <param name="sqlStatement">The SQL statement.</param>
/// <param name="argumentValue">The argument value.</param>
IMultipleTableDbCommandBuilder Sql(string sqlStatement, object argumentValue);
IMultipleTableDbCommandBuilder Sql(string sqlStatement, object? argumentValue = null);
}
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public virtual IReadOnlyCollection<UserDefinedTableTypeMetadata<TObjectName, TDb
/// <summary>
/// Parse a string and return the database specific representation of the database object's name.
/// </summary>
/// <param name="name"></param>
/// <param name="name">Name of the object.</param>
public TObjectName ParseObjectName(string name) => ParseObjectName(null, name);

/// <summary>
Expand All @@ -359,6 +359,12 @@ public virtual IReadOnlyCollection<UserDefinedTableTypeMetadata<TObjectName, TDb
/// <remarks>This assumes the column name wasn't already quoted.</remarks>
public abstract string QuoteColumnName(string columnName);

/// <summary>
/// Parse a string and return the database specific representation of the database object's name as a quoted string.
/// </summary>
/// <param name="name">Name of the object.</param>
public abstract string QuoteObjectName(string name);

/// <summary>
/// Registers a database type and its CLR equivalent.
/// </summary>
Expand Down
Loading