private static void AddScalarMember( Type type, PropertyInfo clrProperty, StructuralType ospaceType, EdmProperty cspaceProperty, EdmType propertyType) { DebugCheck.NotNull(type); DebugCheck.NotNull(clrProperty); Debug.Assert(clrProperty.CanRead && clrProperty.CanWriteExtended(), "The clr property has to have a setter and a getter."); DebugCheck.NotNull(ospaceType); DebugCheck.NotNull(cspaceProperty); DebugCheck.NotNull(propertyType); Debug.Assert(Helper.IsScalarType(propertyType), "Property has to be primitive or enum."); var cspaceType = cspaceProperty.DeclaringType; var isKeyMember = Helper.IsEntityType(cspaceType) && ((EntityType)cspaceType).KeyMemberNames.Contains(clrProperty.Name); // the property is nullable only if it is not a key and can actually be set to null (i.e. is not a value type or is a nullable value type) var nullableFacetValue = !isKeyMember && (!clrProperty.PropertyType.IsValueType || Nullable.GetUnderlyingType(clrProperty.PropertyType) != null); var ospaceProperty = new EdmProperty( cspaceProperty.Name, TypeUsage.Create( propertyType, new FacetValues { Nullable = nullableFacetValue }), clrProperty, type); if (isKeyMember) { ((EntityType)ospaceType).AddKeyMember(ospaceProperty); } else { ospaceType.AddMember(ospaceProperty); } }
// <summary> // Determines if the given edmType is order comparable. Consult "EntitySql Language Specification", // section 7 - Comparison and Dependent Operations for details. // </summary> // <param name="edmType"> an instance of an EdmType </param> // <returns> true if edmType is order-comparable, false otherwise </returns> private static bool IsOrderComparable(EdmType edmType) { // only primitive and enum types are assumed to be order-comparable though they // may still fail during runtime depending on the provider specific behavior return(Helper.IsScalarType(edmType)); }
private static bool IsOrderComparable(EdmType edmType) { return(Helper.IsScalarType(edmType)); }