Beispiel #1
0
        private void TransferLoadedAssemblies(ObjectContextProxy source)
        {
            IEnumerable <GlobalItem> objectItemCollection = source.GetObjectItemCollection();

            foreach (Assembly assembly in objectItemCollection.Where <GlobalItem>((Func <GlobalItem, bool>)(i =>
            {
                if (!(i is EntityType))
                {
                    return(i is ComplexType);
                }
                return(true);
            })).Select <GlobalItem, Assembly>((Func <GlobalItem, Assembly>)(i => source.GetClrType((StructuralType)i).Assembly())).Union <Assembly>(objectItemCollection.OfType <EnumType>().Select <EnumType, Assembly>((Func <EnumType, Assembly>)(i => source.GetClrType(i).Assembly()))).Distinct <Assembly>())
            {
                this._objectContext.LoadFromAssembly(assembly);
            }
        }
        // <summary>
        // Finds the assemblies that were used for loading o-space types in the source context
        // and loads those assemblies in the cloned context.
        // </summary>
        private void TransferLoadedAssemblies(ObjectContextProxy source)
        {
            DebugCheck.NotNull(source);

            var objectItemCollection = source.GetObjectItemCollection();

            var assemblies = objectItemCollection
                             .Where(i => i is EntityType || i is ComplexType)
                             .Select(i => source.GetClrType((StructuralType)i).Assembly())
                             .Union(
                objectItemCollection.OfType <EnumType>()
                .Select(i => source.GetClrType(i).Assembly()))
                             .Distinct();

            foreach (var assembly in assemblies)
            {
                _objectContext.LoadFromAssembly(assembly);
            }
        }