-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Functional.Marten to Functional directory, publish nuget packages
- Loading branch information
1 parent
d4c9ae9
commit 92f06ce
Showing
12 changed files
with
129 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
src/Codehard.Functional.Marten/DocumentSessionExtensions.cs
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
src/Codehard.Functional.Marten/PagedListQueryableExtensions.cs
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
92 changes: 92 additions & 0 deletions
92
src/Codehard.Functional/Codehard.Functional.Marten/DocumentSessionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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<Unit> 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<Unit> 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<Unit> 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<Unit> 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; | ||
}); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Codehard.Functional/Codehard.Functional.Marten/PagedListQueryableExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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<T> 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<IPagedList<T>> 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)); | ||
} | ||
} |
File renamed without changes.