Skip to content

Commit

Permalink
Add project files.
Browse files Browse the repository at this point in the history
  • Loading branch information
VarunSaiTeja committed Jan 9, 2022
1 parent 2a0d6a9 commit 2c90b37
Show file tree
Hide file tree
Showing 21 changed files with 1,650 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/TryMe/bin/Debug/net6.0/TryMe.dll",
"args": [],
"cwd": "${workspaceFolder}/TryMe",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}
42 changes: 42 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/TryMe/TryMe.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/TryMe/TryMe.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/TryMe/TryMe.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}
31 changes: 31 additions & 0 deletions FirestoreLINQ.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32014.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FirestoreLINQ", "FirestoreLINQ\FirestoreLINQ.csproj", "{A6355CF0-4771-4141-9A79-4AC0C173E7BE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestCases", "TestCases\TestCases.csproj", "{57CE4032-4469-4B84-B497-5677477C513D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A6355CF0-4771-4141-9A79-4AC0C173E7BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A6355CF0-4771-4141-9A79-4AC0C173E7BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A6355CF0-4771-4141-9A79-4AC0C173E7BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A6355CF0-4771-4141-9A79-4AC0C173E7BE}.Release|Any CPU.Build.0 = Release|Any CPU
{57CE4032-4469-4B84-B497-5677477C513D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{57CE4032-4469-4B84-B497-5677477C513D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{57CE4032-4469-4B84-B497-5677477C513D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{57CE4032-4469-4B84-B497-5677477C513D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F9B6A308-A107-4CA6-BEAC-36460E4634F4}
EndGlobalSection
EndGlobal
13 changes: 13 additions & 0 deletions FirestoreLINQ/Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Google.Cloud.Firestore;

namespace FirestoreLINQ
{
public static class Extensions
{
public static IQueryable<T> AsQuerable<T>(this CollectionReference collection)
{
IQueryable<T> source = new Queryable<T>(collection);
return source;
}
}
}
13 changes: 13 additions & 0 deletions FirestoreLINQ/FirestoreLINQ.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Google.Cloud.Firestore" Version="2.4.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

</Project>
40 changes: 40 additions & 0 deletions FirestoreLINQ/GenericAggregator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Google.Cloud.Firestore;

namespace FirestoreLINQ
{
internal partial class QueryProvider
{
public class GenericAggregator<T>
{
public static T Aggregate(QuerySnapshot snapshot, string Aggregator)
{
object result = null;

if (typeof(T) == typeof(int))
{
List<int> results = snapshot.Select(x => x.ConvertTo<Dictionary<string, int>>().Values.First()).ToList();
result = Aggregator == "Sum" ? results.Sum() : results.Average();
}
else if (typeof(T) == typeof(long))
{
List<long> results = snapshot.Select(x => x.ConvertTo<Dictionary<string, long>>().Values.First()).ToList();
result = Aggregator == "Sum" ? results.Sum() : results.Average();
}
else if (typeof(T) == typeof(decimal))
{
List<decimal> results = snapshot.Select(x => x.ConvertTo<Dictionary<string, decimal>>().Values.First()).ToList();
result = Aggregator == "Sum" ? results.Sum() : results.Average();
}
else if (typeof(T) == typeof(double))
{
List<double> results = snapshot.Select(x => x.ConvertTo<Dictionary<string, double>>().Values.First()).ToList();
result = Aggregator == "Sum" ? results.Sum() : results.Average();
}
else
throw new NotImplementedException($"Operation is not implemented for {typeof(T)}");

return (T)Convert.ChangeType(result, typeof(T));
}
}
}
}
Loading

0 comments on commit 2c90b37

Please sign in to comment.