Esempio n. 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.");
 }
Esempio n. 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);
        }
Esempio n. 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;
        }
Esempio n. 4
0
        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;
        }
Esempio n. 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));
 }
Esempio n. 6
0
 public override IODataNavigable NavigateByEntityTypeKey(EntityFramework edmx)
 {
     throw new NotImplementedException();
 }
Esempio n. 7
0
 public IODataNavigable NavigateByEntityTypeKey(EntityFramework edmx)
 {
     throw new NotSupportedException();
 }
Esempio n. 8
0
 public override void ApplyTransformation(BaseModifications value, EntityFramework edmx, string[] versions)
 {
     base.ApplyTransformation(value, edmx, versions);
 }
Esempio n. 9
0
 public IODataNavigable NavigateByEntityTypeKey(EntityFramework edmx)
 {
     throw new NotSupportedException();
 }
Esempio n. 10
0
 public IODataNavigable NavigateByUriComponent(string component, EntityFramework edmx)
 {
     throw new NotSupportedException();
 }
Esempio n. 11
0
 public IODataNavigable NavigateByEntityTypeKey(EntityFramework edmx)
 {
     return(edmx.ResourceWithIdentifier <IODataNavigable>(this.TypeIdentifier));
 }
Esempio n. 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();
        }
Esempio n. 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));
 }
Esempio n. 14
0
 public IODataNavigable NavigateByEntityTypeKey(EntityFramework edmx)
 {
     return edmx.ResourceWithIdentifier<IODataNavigable>(this.TypeIdentifier);
 }
Esempio n. 15
0
 public IODataNavigable NavigateByUriComponent(string component, EntityFramework edmx)
 {
     throw new NotSupportedException();
 }
Esempio n. 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);
 }
Esempio n. 17
0
 public override IODataNavigable NavigateByEntityTypeKey(EntityFramework edmx)
 {
     throw new NotImplementedException();
 }
Esempio n. 18
0
 public void ApplyTransformation(BaseModifications mods, EntityFramework edmx, string[] versions)
 {
     TransformationHelper.ApplyTransformation(this, mods, edmx, versions);
 }