-
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.
Merge branch 'release/universe-1.2.0' into prod
- Loading branch information
Showing
20 changed files
with
662 additions
and
125 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
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,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>disable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Universe\UniverseQuery.csproj" /> | ||
</ItemGroup> | ||
</Project> |
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,75 @@ | ||
using Microsoft.Azure.Cosmos; | ||
using Universe; | ||
using Universe.Interfaces; | ||
using Universe.Options; | ||
using Universe.Options.Query; | ||
using Universe.Response; | ||
|
||
string CosmosDbUri = "<FROM AZURE>"; | ||
string CosmosDbPrimaryKey = "<FROM AZURE>"; | ||
|
||
// Imagine this part here as your dependency injection | ||
CosmosClient cosmosClient = new( | ||
CosmosDbUri, | ||
CosmosDbPrimaryKey, | ||
clientOptions: new() | ||
{ | ||
Serializer = new UniverseSerializer() | ||
} | ||
); | ||
|
||
IGalaxy<MyObject> galaxy = new MyRepo( | ||
db: cosmosClient.GetDatabase("<DATABASE NAME>"), | ||
container: "<CONTAINER NAME>", | ||
partitionKey: "/<PARTITION KEY>" | ||
); | ||
// end of dependency injection | ||
|
||
// actual use of UniverseQuery | ||
(Gravity g, IList<MyObject> T) = await galaxy.Paged( | ||
page: new Q.Page(50), | ||
catalysts: new List<Catalyst> | ||
{ | ||
new(nameof(MyObject.Links), "<VALUE TO QUERY>", Operator: Q.Operator.In), | ||
new(nameof(MyObject.Code), "<VALUE TO QUERY>", Where: Q.Where.Or) | ||
}, | ||
columns: new List<string> | ||
{ | ||
nameof(MyObject.id), | ||
nameof(MyObject.Code), | ||
nameof(MyObject.Name), | ||
nameof(MyObject.Description) | ||
}, | ||
sorting: new List<Sorting.Option> | ||
{ | ||
new(nameof(MyObject.Name), Sorting.Direction.DESC) | ||
} | ||
); | ||
|
||
Console.WriteLine($"RU Spent: {g.RU}"); | ||
Console.ReadLine(); | ||
|
||
// Object definitions | ||
class MyObject : ICosmicEntity | ||
{ | ||
// Universe Generated | ||
public string id { get; set; } | ||
public DateTime AddedOn { get; set; } | ||
public DateTime? ModifiedOn { get; set; } | ||
public string PartitionKey => Code; | ||
|
||
public string Code { get; set; } | ||
|
||
public string Name { get; set; } | ||
|
||
public string Description { get; set; } | ||
|
||
public string[] Links { get; set; } | ||
} | ||
|
||
class MyRepo : Galaxy<MyObject> | ||
{ | ||
public MyRepo(Database db, string container, string partitionKey) : base(db, container, partitionKey) | ||
{ | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
Oops, something went wrong.