Skip to content

Commit

Permalink
Move Functional.Marten to Functional directory, publish nuget packages
Browse files Browse the repository at this point in the history
  • Loading branch information
rungwiroon committed Nov 14, 2023
1 parent d4c9ae9 commit 92f06ce
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 37 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ jobs:
with:
PROJECT_FILE_PATH: src/Codehard.Functional/Codehard.Functional.EntityFramework/Codehard.Functional.EntityFramework.csproj
NUGET_KEY: ${{secrets.NUGET_API_KEY}}
- name: Publish Codehard.Functional.Marten To Nuget
uses: brandedoutcast/[email protected]
with:
PROJECT_FILE_PATH: src/Codehard.Functional/Codehard.Functional.Marten/Codehard.Functional.Marten.csproj
NUGET_KEY: ${{secrets.NUGET_API_KEY}}

publish-common:
runs-on: ubuntu-latest
Expand Down
8 changes: 4 additions & 4 deletions src/Codehard.Core.sln
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Codehard.Functional.AspNetC
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Codehard.Infrastructure.EntityFramework.Tests", "Codehard.Infrastructure\Codehard.Infrastructure.EntityFramework.Tests\Codehard.Infrastructure.EntityFramework.Tests.csproj", "{0281E666-6C4E-4F4C-BDC7-1A71D781D34D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Codehard.DomainModel.Generator", "Codehard.Common/Codehard.DomainModel.Generator\Codehard.DomainModel.Generator.csproj", "{0864E7FA-1BE2-4703-9F96-91386753B301}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Codehard.DomainModel.Generator", "Codehard.Common\Codehard.DomainModel.Generator\Codehard.DomainModel.Generator.csproj", "{0864E7FA-1BE2-4703-9F96-91386753B301}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Codehard.DomainModel.Generator.Tests", "Codehard.Common/Codehard.DomainModel.Generator.Tests\Codehard.DomainModel.Generator.Tests.csproj", "{6277AC9F-217C-4F89-8589-51FCB4E9BADF}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Codehard.DomainModel.Generator.Tests", "Codehard.Common\Codehard.DomainModel.Generator.Tests\Codehard.DomainModel.Generator.Tests.csproj", "{6277AC9F-217C-4F89-8589-51FCB4E9BADF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Codehard.Functional.Marten", "Codehard.Functional.Marten\Codehard.Functional.Marten.csproj", "{8D62918D-C27F-45AF-B26A-437B594C0D5C}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Codehard.Functional.Marten", "Codehard.Functional\Codehard.Functional.Marten\Codehard.Functional.Marten.csproj", "{8D62918D-C27F-45AF-B26A-437B594C0D5C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Codehard.Functional.Marten.Tests", "Codehard.Functional.Marten.Tests\Codehard.Functional.Marten.Tests.csproj", "{BCB6D4C3-DD27-43AD-B0E9-6C8DE6821AD5}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Codehard.Functional.Marten.Tests", "Codehard.Functional\Codehard.Functional.Marten.Tests\Codehard.Functional.Marten.Tests.csproj", "{BCB6D4C3-DD27-43AD-B0E9-6C8DE6821AD5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
14 changes: 0 additions & 14 deletions src/Codehard.Functional.Marten/DocumentSessionExtensions.cs

This file was deleted.

19 changes: 0 additions & 19 deletions src/Codehard.Functional.Marten/PagedListQueryableExtensions.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
using LanguageExt;

using static LanguageExt.Prelude;

// ReSharper disable once CheckNamespace
namespace Marten;

/// <summary>
///
/// </summary>
public static class DocumentSessionExtensions
{
/// <summary>
/// Save changes to the database
/// </summary>
public static Aff<Unit> SaveChangesAff(this IDocumentSession documentSession)
{
return Aff(async () => await documentSession.SaveChangesAsync().ToUnit());
}

/// <summary>
/// Eff monad wrapper for storing entities in Marten's IDocumentSession.
/// </summary>
/// <typeparam name="T">The type of the entities to store.</typeparam>
/// <param name="documentSession">The Marten IDocumentSession to use for storing entities.</param>
/// <param name="entities">The entities to store in the document session.</param>
/// <returns>An Eff&lt;Unit&gt; representing the side-effect of storing entities in the document session.</returns>
public static Eff<Unit> StoreEff<T>(this IDocumentSession documentSession, params T[] entities)
where T : notnull
{
return Eff(() =>
{
documentSession.Store(entities);

return unit;
});
}

/// <summary>
/// Eff monad wrapper for updating entities in Marten's IDocumentSession.
/// </summary>
/// <typeparam name="T">The type of the entities to update.</typeparam>
/// <param name="documentSession">The Marten IDocumentSession to use for updating entities.</param>
/// <param name="entities">The entities to update in the document session.</param>
/// <returns>An Eff&lt;Unit&gt; representing the side-effect of updating entities in the document session.</returns>
public static Eff<Unit> UpdateEff<T>(this IDocumentSession documentSession, params T[] entities)
where T : notnull
{
return Eff(() =>
{
documentSession.Update(entities);

return unit;
});
}

/// <summary>
/// Eff monad wrapper for updating entities in Marten's IDocumentSession.
/// </summary>
/// <typeparam name="T">The type of the entities to update.</typeparam>
/// <param name="documentSession">The Marten IDocumentSession to use for updating entities.</param>
/// <param name="entities">The entities to update in the document session.</param>
/// <returns>An Eff&lt;Unit&gt; representing the side-effect of updating entities in the document session.</returns>
public static Eff<Unit> DeleteEff<T>(this IDocumentSession documentSession, T entity)
where T : notnull
{
return Eff(() =>
{
documentSession.Delete(entity);

return unit;
});
}

/// <summary>
/// Eff monad wrapper for deleting an entity by its identifier from Marten's IDocumentSession.
/// </summary>
/// <typeparam name="T">The type of the entity to delete.</typeparam>
/// <param name="documentSession">The Marten IDocumentSession to use for deleting the entity.</param>
/// <param name="id">The identifier of the entity to delete.</param>
/// <returns>An Eff&lt;Unit&gt; representing the side-effect of deleting the entity from the document session.</returns>
public static Eff<Unit> DeleteEff<T>(this IDocumentSession documentSession, Guid id)
where T : notnull
{
return Eff(() =>
{
documentSession.Delete<T>(id);

return unit;
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using LanguageExt;

using static LanguageExt.Prelude;

// ReSharper disable once CheckNamespace
namespace Marten.Pagination;

public static class PagedListQueryableExtensions
{
/// <summary>
/// Asynchronously converts an IQueryable&lt;T&gt; into a paginated list within an Aff monad.
/// </summary>
/// <typeparam name="T">The type of elements in the IQueryable.</typeparam>
/// <param name="queryable">The IQueryable to be paginated.</param>
/// <param name="pageNumber">The one-based index of the page to retrieve.</param>
/// <param name="pageSize">The number of items per page.</param>
/// <param name="token">A CancellationToken to observe while waiting for the task to complete.</param>
/// <returns>An Aff&lt;IPagedList&lt;T&gt;&gt; representing the asynchronous operation.
/// The Aff monad wraps the result, which is the paginated list of elements.</returns>
public static Aff<IPagedList<T>> ToPagedListAff<T>(
this IQueryable<T> queryable,
int pageNumber,
int pageSize,
CancellationToken token = default)
{
return Aff(async () => await queryable.ToPagedListAsync(pageNumber, pageSize, token));
}
}

0 comments on commit 92f06ce

Please sign in to comment.