Skip to content

Commit

Permalink
Fix version < 4
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardIrons-neo4j committed Feb 8, 2024
1 parent a10f6d2 commit 490b8e2
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions Repositories/MovieRepository.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices.ComTypes;
using System.Threading.Tasks;
using MoviesDotNetCore.Model;
using Neo4j.Driver;
Expand All @@ -18,12 +20,20 @@ public interface IMovieRepository
public class MovieRepository : IMovieRepository
{
private readonly IDriver _driver;

private readonly QueryConfig _queryConfig = new (
database: Environment.GetEnvironmentVariable("NEO4J_DATABASE") ?? "movies");
private readonly QueryConfig _queryConfig;

public MovieRepository(IDriver driver)
{
var versionStr = Environment.GetEnvironmentVariable("NEO4J_VERSION") ?? "";
if( double.TryParse(versionStr, out var version) && version >= 4.0)
{
_queryConfig = new QueryConfig(database: Environment.GetEnvironmentVariable("NEO4J_DATABASE") ?? "movies");
}
else
{
_queryConfig = new QueryConfig();
}

_driver = driver;
}

Expand Down

0 comments on commit 490b8e2

Please sign in to comment.