public virtual IODataNavigable NavigateByUriComponent(string component, EntityFramework edmx, IssueLogger issues, bool isLastSegment) { var func = this.NavigateByFunction(component, edmx, isLastSegment); if (func != null) { return(func); } var match = this.Properties.Where(p => p.Name == component).Select(p => p.Type).FirstOrDefault(); if (match != null) { return(edmx.ResourceWithIdentifier <IODataNavigable>(match)); } // check for case-insensitive matches and throw if one exists var otherCaseName = this.Properties.Where(p => p.Name.IEquals(component)).Select(p => p.Name).FirstOrDefault(); if (otherCaseName != null) { throw new ArgumentException($"ERROR: case mismatch between URL segment '{component}' and schema element '{otherCaseName}'"); } return(null); }
private static void MergeInheritedProperties(EntityFramework dataServices, ComplexType complexType) { ComplexType baseComplexType = dataServices.ResourceWithIdentifier <ComplexType>(complexType.BaseType); while (baseComplexType != null) { for (int i = baseComplexType.Properties.Count - 1; i >= 0; i--) { if (!complexType.Properties.Contains(baseComplexType.Properties[i])) { complexType.Properties.Insert(0, baseComplexType.Properties[i]); } } if (baseComplexType.BaseType != null) { baseComplexType = dataServices.ResourceWithIdentifier <ComplexType>(baseComplexType.BaseType); } else { break; } } }
public static IODataNavigable NavigateByFunction(this IODataNavigable source, string component, EntityFramework edmx, bool isLastSegment) { var matches = edmx.DataServices.Schemas.SelectMany(s => s.Functions). Where(f => f.IsBound && (f.Name == component || f.ParameterizedName == component) && f.ReturnType?.Type != null && f.Parameters.Any(p => p.Name == "bindingParameter" && p.Type.TypeOnly() == source.TypeIdentifier.TypeOnly())). ToList(); if (matches.Any()) { foreach (var m in matches) { m.IsComposable = true; } var match = matches.First().ReturnType.Type; return(edmx.ResourceWithIdentifier <IODataNavigable>(match)); } var otherCaseName = edmx.DataServices.Schemas.SelectMany(s => s.Functions). Where(f => f.IsBound && (f.Name.IEquals(component) || f.ParameterizedName.IEquals(component)) && f.Parameters.Any(p => p.Name == "bindingParameter" && p.Type.TypeOnly() == source.TypeIdentifier.TypeOnly())). Select(f => f.Name.IEquals(component) ? f.Name : f.ParameterizedName). FirstOrDefault(); if (otherCaseName != null) { throw new ArgumentException($"ERROR: case mismatch between URL segment '{component}' and schema element '{otherCaseName}'"); } return(null); }
public IODataNavigable NavigateByUriComponent(string component, EntityFramework edmx, IssueLogger issues, bool isLastSegment) { string targetType = null; var entitySet = (from e in EntitySets where e.Name == component select e).FirstOrDefault(); if (null != entitySet) { // EntitySet is always a collection of an item type targetType = "Collection(" + entitySet.EntityType + ")"; } else { var singleton = (from s in Singletons where s.Name == component select s).FirstOrDefault(); if (null != singleton) { targetType = singleton.Type; } } if (targetType != null) { if (targetType.StartsWith("Collection(")) { var innerId = targetType.Substring(11, targetType.Length - 12); return(new ODataCollection(innerId)); } return(edmx.ResourceWithIdentifier <IODataNavigable>(targetType)); } return(null); }
public IODataNavigable NavigateByEntityTypeKey(EntityFramework edmx, IssueLogger issues) { return(edmx.ResourceWithIdentifier <IODataNavigable>(this.TypeIdentifier)); }