Esempio n. 1
0
        internal static List <OperationImportModel> GetOperationsImports(IEdmModel model, string proxyClassNamespace, string endpointUri)
        {
            var result = new List <OperationImportModel>();

            if (model == null)
            {
                return(result);
            }

            foreach (var modelEntityContainer in model.EntityContainers())
            {
                foreach (var operationImport in modelEntityContainer.OperationImports())
                {
                    result.Add(new OperationImportModel(model, operationImport, endpointUri, proxyClassNamespace));
                }
            }

            return(result);
        }
Esempio n. 2
0
        public static void UpgradeBidirectionalNavigationProperties(Microsoft.OData.Edm.IEdmModel model, string setName, string partnerSetName, string elementTypeName, string partnerElementTypeName, string navigationName, string partnerName, EdmMultiplicity multipl, EdmMultiplicity partnerMultipl)
        {
            var fromSet    = (EdmEntitySet)model.EntityContainer.FindEntitySet(setName);
            var partnerSet = (EdmEntitySet)model.EntityContainer.FindEntitySet(partnerSetName);

            var fromType    = (EdmEntityType)model.FindDeclaredType(elementTypeName);
            var partnerType = (EdmEntityType)model.FindDeclaredType(partnerElementTypeName);

            if (fromType == null)
            {
                throw new Exception("fromType is null");
            }

            if (partnerType == null)
            {
                throw new Exception("partnerType is null");
            }

            var partsProperty = new EdmNavigationPropertyInfo();

            partsProperty.Name = navigationName;
            partsProperty.TargetMultiplicity = multipl;
            partsProperty.Target             = partnerType;
            partsProperty.ContainsTarget     = false;
            partsProperty.OnDelete           = EdmOnDeleteAction.None;

            var partnerProperty = new EdmNavigationPropertyInfo();

            partnerProperty.Name = partnerName;
            partnerProperty.TargetMultiplicity = partnerMultipl;
            partnerProperty.Target             = fromType;
            partnerProperty.ContainsTarget     = false;
            partnerProperty.OnDelete           = EdmOnDeleteAction.None;

            fromSet.AddNavigationTarget(fromType.AddBidirectionalNavigation(partsProperty, partnerProperty), partnerSet);
        }