Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LLBLGenProODataQueryProvider&lt;TLinqMetaData&gt;"/> class.
 /// </summary>
 /// <param name="metaDataProvider">The meta data provider.</param>
 /// <param name="containingService">The containing service.</param>
 public LLBLGenProODataQueryProvider(LLBLGenProODataServiceMetadataProvider metaDataProvider,
                                     LLBLGenProODataServiceBase <TLinqMetaData> containingService)
 {
     if (metaDataProvider == null)
     {
         throw new ArgumentNullException(nameof(metaDataProvider));
     }
     if (containingService == null)
     {
         throw new ArgumentNullException(nameof(containingService));
     }
     _containingService = containingService;
     _metaDataProvider  = metaDataProvider;
 }
        /// <summary>
        /// Gets the instance cached under the key specified.
        /// </summary>
        /// <param name="serviceType">Type of the service.</param>
        /// <returns></returns>
        internal static LLBLGenProODataServiceMetadataProvider GetInstance(Type serviceType)
        {
            _cacheLock.EnterReadLock();
            LLBLGenProODataServiceMetadataProvider toReturn = null;

            try
            {
                _cache.TryGetValue(serviceType, out toReturn);
            }
            finally
            {
                _cacheLock.ExitReadLock();
            }
            return(toReturn);
        }
Пример #3
0
 /// <summary>
 /// Gets the model meta data.
 /// </summary>
 /// <returns>ready to use ModelMetaData class</returns>
 private LLBLGenProODataServiceMetadataProvider GetModelMetadata()
 {
     if (_modelMetadata == null)
     {
         _modelMetadata = MetaDataCache.GetInstance(this.GetType());
         if (_modelMetadata == null)
         {
             // not yet in cache. Create new one.
             var newModelMetadata = new LLBLGenProODataServiceMetadataProvider(this.GetType(), typeof(TLinqMetaData), this.ContainerName,
                                                                               this.ContainerNamespace, this.AllowSubTypeNavigators);
             _modelMetadata = MetaDataCache.AddInstance(this.GetType(), newModelMetadata);
         }
     }
     return(_modelMetadata);
 }
        /// <summary>
        /// Adds the instance specified, if there isn't an element with the key specified in the cache. If there is an element in the cache with the
        /// key specified, that element is returned.
        /// </summary>
        /// <param name="serviceType">Type of the service.</param>
        /// <param name="metaDataProvider">The meta data provider.</param>
        /// <returns></returns>
        internal static LLBLGenProODataServiceMetadataProvider AddInstance(Type serviceType, LLBLGenProODataServiceMetadataProvider metaDataProvider)
        {
            LLBLGenProODataServiceMetadataProvider toReturn = null;

            _cacheLock.EnterWriteLock();
            try
            {
                if (!_cache.TryGetValue(serviceType, out toReturn))
                {
                    _cache.Add(serviceType, metaDataProvider);
                    toReturn = metaDataProvider;
                }
            }
            finally
            {
                _cacheLock.ExitWriteLock();
            }
            return(toReturn);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="LLBLGenProODataServiceUpdateProvider"/> class.
 /// </summary>
 /// <param name="unitOfWork">The unit of work.</param>
 /// <param name="transactionControllerCreatorFunc">The transaction controller creator func.</param>
 /// <param name="metaDataProvider">The meta data provider.</param>
 public LLBLGenProODataServiceUpdateProvider(IUnitOfWorkCore unitOfWork, Func <ITransactionController> transactionControllerCreatorFunc,
                                             LLBLGenProODataServiceMetadataProvider metaDataProvider)
 {
     if (unitOfWork == null)
     {
         throw new ArgumentNullException(nameof(unitOfWork));
     }
     if (transactionControllerCreatorFunc == null)
     {
         throw new ArgumentNullException(nameof(transactionControllerCreatorFunc));
     }
     if (metaDataProvider == null)
     {
         throw new ArgumentNullException(nameof(metaDataProvider));
     }
     _uow = unitOfWork;
     _transactionControllerCreatorFunc = transactionControllerCreatorFunc;
     _metaDataProvider = metaDataProvider;
     // make sure the entity is marked as saved after a save, as re-fetching is not needed.
     EntityBase.MarkSavedEntitiesAsFetched  = true;
     EntityBase2.MarkSavedEntitiesAsFetched = true;
 }