コード例 #1
0
        public void GetAllNodes()
        {
            using (var client = new NeoClient(URL, USER, PASSWORD, CONFIG))
            {
                client.Connect();

                var userList = new List <User>();

                for (int i = 0; i < 10; i++)
                {
                    userList.Add(new User
                    {
                        Email     = "*****@*****.**",
                        FirstName = $"FakeFirstName{i}",
                        LastName  = $"FakeLastName{i}"
                    });
                }

                userList.ForEach((user) => client.Add(user));

                IList <User> entities = client.GetAll <User>();

                entities.Should().NotBeNullOrEmpty();
            }
        }
コード例 #2
0
        public IHttpActionResult SearchMoviesByTitle(string q = "Matrix")
        {
            IList <Movie> movies = null;

            using (var client = new NeoClient(WebApiConfig.url, WebApiConfig.userName, WebApiConfig.password, WebApiConfig.config))
            {
                client.Connect();

                movies = client.GetAll <Movie>($"n.title CONTAINS '{q}'");
            }

            return(Ok(movies?.Select(m => new { movie = m })));
        }
コード例 #3
0
        public IHttpActionResult Index(int limit = 100)
        {
            var nodes         = new List <NodeResult>();
            var relationships = new List <object>();
            var config        = Config.Builder
                                .WithEncryptionLevel(EncryptionLevel.None)
                                .ToConfig();

            using (var client = new NeoClient(WebApiConfig.url, WebApiConfig.userName, WebApiConfig.password, WebApiConfig.config))
            {
                client.Connect();

                IList <Movie> movieList = client
                                          .GetAll <Movie>()
                                          .Where(p => p.ActorList != null)
                                          .ToList();

                var i = 0;

                foreach (var movie in movieList)
                {
                    var target = i;
                    nodes.Add(new NodeResult {
                        title = movie.title, label = movie.Label
                    });
                    i += 1;

                    var castMembers = movie.ActorList;
                    foreach (var castMember in castMembers)
                    {
                        var source = nodes.FindIndex(c => c.title == castMember.name);
                        if (source == -1)
                        {
                            nodes.Add(new NodeResult {
                                title = castMember.name, label = "actor"
                            });
                            source = i;
                            i     += 1;
                        }
                        relationships.Add(new { source, target });
                    }
                }
            }

            return(Ok(new { nodes, links = relationships }));
        }