Пример #1
0
        /// <summary>
        /// Example for traversing a model
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TraverseButton_Click(object sender, EventArgs e)
        {
            const int indent = 20;

            ReadOnlyMetadataCollection <NavigationProperty> metadata = EntityFrameworkHelper.GetNavigationProperties <Order, NorthContext>();

            var nameParts = metadata.FirstOrDefault().DeclaringType.FullName.Split('.');

            Debug.WriteLine($"namespace: {nameParts[0]}");
            Debug.WriteLine($"    class: {nameParts[1]}");

            Debug.WriteLine("");

            Debug.WriteLine("navigation model names");

            var navigationPropertyNames = metadata.Select(np => np.Name).ToList();


            foreach (var name in navigationPropertyNames)
            {
                Debug.WriteLine($"{name,indent}");
            }

            Debug.WriteLine("");
            Debug.WriteLine("RelationshipType names");
            var relationNames = metadata.Select(np => np.RelationshipType.Name).ToList();

            foreach (var relationName in relationNames)
            {
                Debug.WriteLine($"{relationName,indent}");
            }


            MessageBox.Show("See output window");
        }