Exemple #1
0
        /// <summary>
        /// Access the RDF data using the entity framework
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="storeName"></param>
        static void PrintOutUsingEntityFramework(string connectionString, string storeName)
        {
            Console.WriteLine("Print out store data using Entity Framework...");
            //connect to the same store using the BrightstarDB entity framework context
            var context = new FoafContext(connectionString + "StoreName=" + storeName);

            //loop through all the Person entities and print out their properties and other people that they 'know'
            Console.WriteLine(@"{0} people found in raw RDF data", context.Persons.Count());
            Console.WriteLine();
            foreach (var person in context.Persons.ToList())
            {
                Console.WriteLine("PERSON ID: {0}", person.Id);
                var knows = new List <IPerson>();
                knows.AddRange(person.Knows);
                knows.AddRange(person.KnownBy);

                Console.WriteLine(@"Full Name: {0}. Nickname: {1}. Employer: {2}", person.Name, person.Nickname, person.Organisation);
                Console.WriteLine(knows.Count == 1
                                      ? string.Format(@"{0} knows 1 other person", person.Nickname)
                                      : string.Format(@"{0} knows {1} other people", person.Nickname, knows.Count));
                foreach (var other in knows)
                {
                    Console.WriteLine(@"    {0} at {1}", other.Name, other.Organisation);
                }
                Console.WriteLine();
            }
        }
Exemple #2
0
        /// <summary>
        /// Access the RDF data using the entity framework
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="storeName"></param>
        static void PrintOutUsingEntityFramework(string connectionString, string storeName)
        {
            Console.WriteLine("Print out store data using Entity Framework...");
            //connect to the same store using the BrightstarDB entity framework context
            var context = new FoafContext(connectionString + "StoreName=" + storeName);
            
            //loop through all the Person entities and print out their properties and other people that they 'know'
            Console.WriteLine(@"{0} people found in raw RDF data", context.Persons.Count());
            Console.WriteLine();
            foreach (var person in context.Persons.ToList())
            {
                Console.WriteLine("PERSON ID: {0}", person.Id);
                var knows = new List<IPerson>();
                knows.AddRange(person.Knows);
                knows.AddRange(person.KnownBy);

                Console.WriteLine(@"Full Name: {0}. Nickname: {1}. Employer: {2}", person.Name, person.Nickname, person.Organisation);
                Console.WriteLine(knows.Count == 1
                                      ? string.Format(@"{0} knows 1 other person", person.Nickname)
                                      : string.Format(@"{0} knows {1} other people", person.Nickname, knows.Count));
                foreach(var other in knows)
                {
                    Console.WriteLine(@"    {0} at {1}", other.Name, other.Organisation);
                }
                Console.WriteLine();
            }
        }