Example #1
0
        public static IEntityType GetEntityTypeOrThrow(this IModelContext context, string name)
        {
            IEntityType entityType;

            if (context.TryGetEntityType(name, out entityType))
            {
                return(entityType);
            }

            throw new KeyNotFoundException("Entity type not found: " + name);
        }
Example #2
0
        public static IEntityType GetEntityType(this ODataEntityDto oDataEntity, IModelContext context)
        {
            var edmEntityType = context.EdmModel.FindDeclaredType(oDataEntity.Entry.TypeName);

            if (edmEntityType != null)
            {
                IEntityType entityType;
                if (context.TryGetEntityType(edmEntityType.Name, out entityType))
                {
                    return(entityType);
                }
            }

            throw new KeyNotFoundException("The entity type " + oDataEntity.Entry.TypeName + " could not be found.");
        }