示例#1
0
 public virtual IODataNavigable NavigateByEntityTypeKey(EntityFramework edmx)
 {
     if (this.OpenType)
     {
         // TODO: This isn't illegal, but we don't know what you're going to get back anyway, so we just treat it the same for now.
     }
     throw new NotSupportedException("ComplexType cannot be navigated by key.");
 }
示例#2
0
        public override IODataNavigable NavigateByUriComponent(string component, EntityFramework edmx)
        {
            var navigationPropertyMatch = (from n in this.NavigationProperties
                                           where n.Name == component
                                           select n).FirstOrDefault();
            if (null != navigationPropertyMatch)
            {
                var identifier = navigationPropertyMatch.Type;
                if (identifier.StartsWith("Collection("))
                {
                    var innerId = identifier.Substring(11, identifier.Length - 12);
                    return new ODataCollection(innerId);
                }
                return edmx.LookupNavigableType(identifier);
            }

            return base.NavigateByUriComponent(component, edmx);
        }
示例#3
0
        public virtual IODataNavigable NavigateByUriComponent(string component, EntityFramework edmx)
        {
            var propertyMatch = (from p in this.Properties
                where p.Name == component
                select p).FirstOrDefault();
            if (null != propertyMatch)
            {
                var identifier = propertyMatch.Type;
                if (identifier.StartsWith("Collection("))
                {
                    var innerId = identifier.Substring(11, identifier.Length - 12);
                    return new ODataCollection(innerId);
                }
                return edmx.ResourceWithIdentifier<IODataNavigable>(identifier);
            }

            return null;
        }
        public IODataNavigable NavigateByUriComponent(string component, EntityFramework edmx)
        {
            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;
        }
示例#5
0
 public IODataNavigable NavigateByUriComponent(string component, EntityFramework edmx)
 {
     // NavigationByUriComponent for a collection means that we have a hard coded key in the example path.
     return(this.NavigateByEntityTypeKey(edmx));
 }
示例#6
0
 public override IODataNavigable NavigateByEntityTypeKey(EntityFramework edmx)
 {
     throw new NotImplementedException();
 }
 public IODataNavigable NavigateByEntityTypeKey(EntityFramework edmx)
 {
     throw new NotSupportedException();
 }
示例#8
0
 public override void ApplyTransformation(BaseModifications value, EntityFramework edmx, string[] versions)
 {
     base.ApplyTransformation(value, edmx, versions);
 }
示例#9
0
 public IODataNavigable NavigateByEntityTypeKey(EntityFramework edmx)
 {
     throw new NotSupportedException();
 }
示例#10
0
 public IODataNavigable NavigateByUriComponent(string component, EntityFramework edmx)
 {
     throw new NotSupportedException();
 }
示例#11
0
 public IODataNavigable NavigateByEntityTypeKey(EntityFramework edmx)
 {
     return(edmx.ResourceWithIdentifier <IODataNavigable>(this.TypeIdentifier));
 }
示例#12
0
        /// <summary>
        /// Generates an entity framework XML file for a given input
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static string GenerateEdmx(EntityFramework input)
        {
            StringBuilder sb = new StringBuilder();
            StringWriter stringWriter = new StringWriter(sb);
            XmlWriter writer = XmlWriter.Create(
                stringWriter,
                new XmlWriterSettings { Encoding = new UTF8Encoding(false), OmitXmlDeclaration = true, Indent = true });

            XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
            ns.Add("edmx", ODataParser.EdmxNamespace);

            XmlSerializer ser = new XmlSerializer(typeof(EntityFramework));
            ser.Serialize(writer, input, ns);
            writer.Flush();

            return sb.ToString();
        }
示例#13
0
 /// <summary>
 /// Look up a type in the EntityFramework based on the type identifier.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="edmx"></param>
 /// <param name="identifier"></param>
 /// <returns></returns>
 public static T ResourceWithIdentifier <T>(this EntityFramework edmx, string identifier)
 {
     return(edmx.DataServices.Schemas.ResourceWithIdentifier <T>(identifier));
 }
示例#14
0
 public IODataNavigable NavigateByEntityTypeKey(EntityFramework edmx)
 {
     return edmx.ResourceWithIdentifier<IODataNavigable>(this.TypeIdentifier);
 }
示例#15
0
 public IODataNavigable NavigateByUriComponent(string component, EntityFramework edmx)
 {
     throw new NotSupportedException();
 }
示例#16
0
 public IODataNavigable NavigateByUriComponent(string component, EntityFramework edmx)
 {
     // NavigationByUriComponent for a collection means that we have a hard coded key in the example path.
     return this.NavigateByEntityTypeKey(edmx);
 }
示例#17
0
 public override IODataNavigable NavigateByEntityTypeKey(EntityFramework edmx)
 {
     throw new NotImplementedException();
 }
示例#18
0
 public void ApplyTransformation(BaseModifications mods, EntityFramework edmx, string[] versions)
 {
     TransformationHelper.ApplyTransformation(this, mods, edmx, versions);
 }