public static string GetInverseProperty(this Association assoc, Csdl.Schema schema, string toRole) { var otherEnd = assoc.Ends.Single(e => e.Role == toRole); var otherType = (EntityType)schema.FindTypeByName(otherEnd.Type); var fromRole = assoc.Ends.Single(e => e != otherEnd).Role; var otherProperty = otherType.NavigationProperties.SingleOrDefault(p => p.FromRole == toRole && p.ToRole == fromRole); return(otherProperty == null ? null : (otherType.Name + "." + otherProperty.Name)); }
public static string TypeNameToCLRType(this Csdl.Schema schema, string typeName, out bool valueType) { EdmSimpleType edmSimpleType; if (Enum.TryParse <EdmSimpleType>(typeName, out edmSimpleType)) { valueType = true; switch (edmSimpleType) { case EdmSimpleType.Binary: valueType = false; return("byte[]"); case EdmSimpleType.Boolean: return("bool"); case EdmSimpleType.Byte: return("byte"); case EdmSimpleType.DateTime: return(nameof(DateTime)); case EdmSimpleType.DateTimeOffset: return(nameof(DateTimeOffset)); case EdmSimpleType.Decimal: return("decimal"); case EdmSimpleType.Double: return("double"); case EdmSimpleType.Float: return("float"); case EdmSimpleType.Guid: return(nameof(Guid)); case EdmSimpleType.Int16: return("short"); case EdmSimpleType.Int32: return("int"); case EdmSimpleType.Int64: return("long"); case EdmSimpleType.SByte: return("sbyte"); case EdmSimpleType.String: valueType = false; return("string"); case EdmSimpleType.Time: return(nameof(DateTime)); default: throw new ArgumentOutOfRangeException(); } } else { var otherType = schema.FindTypeByName(typeName); valueType = !(otherType is EntityType); return(otherType.Name); } }