1 //---------------------------------------------------------------------
2 // <copyright file="keyproperty.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
8 //---------------------------------------------------------------------
11 using System.Collections;
12 using System.Collections.Generic;
13 using System.Diagnostics;
14 using System.Data.Metadata.Edm;
17 namespace System.Data.EntityModel.SchemaObjectModel
20 /// Represents PropertyRef Element for Entity keys and referential constraints
22 internal sealed class PropertyRefElement : SchemaElement
24 #region Instance Fields
25 private StructuredProperty _property = null;
28 #region Public Methods
30 /// construct a KeyProperty object
32 /// <param name="parentElement"></param>
33 public PropertyRefElement(SchemaElement parentElement)
39 #region Public Properties
41 /// property chain from KeyedType to Leaf property
43 public StructuredProperty Property
52 #region Private Methods
54 internal override void ResolveTopLevelNames()
56 Debug.Assert(false, "This method should never be used. Use other overload instead");
60 /// Since this method can be used in different context, this method does not add any errors
61 /// Please make sure that the caller of this methods handles the error case and add errors
64 /// <param name="entityType"></param>
65 /// <returns></returns>
66 internal bool ResolveNames(SchemaEntityType entityType)
68 if (string.IsNullOrEmpty(this.Name))
70 // Don't flag this error. This must already must have flaged as error, while handling name attribute
74 // Make sure there is a property by this name
75 _property = entityType.FindProperty(this.Name);
77 return (_property != null);