コード例 #1
0
 public void SetUp()
 {
     _mockRepository = new MockRepository();
     _simpleDbProxy = _mockRepository.StrictMock<ISimpleDbProxy>();
     _entityMapper = _mockRepository.StrictMock<IEntityMapper>();
     _formEventRepository = new FormEventRepository(_simpleDbProxy, _entityMapper);
 }
コード例 #2
0
 public TrackingController(IFormEventTrackingService formEventTrackingService,
     IPageEventTrackingService pageEventTrackingService,
     IEntityMapper entityMapper)
 {
     _formEventTrackingService = formEventTrackingService;
     _pageEventTrackingService = pageEventTrackingService;
     _entityMapper = entityMapper;
 }
コード例 #3
0
        public SvnCommitProvider(IEntityMapper mapper, IValidator validator)
        {
            MaxCountOfCommits = 30;
            MaxRepositoryDiscoverDepth = 1000;

            _mapper = mapper;
            _validator = validator;
        }
コード例 #4
0
        public void SetUp()
        {
            _mockRepository = new MockRepository();

            _formEventTrackingService = _mockRepository.StrictMock<IFormEventTrackingService>();
            _pageEventTrackingService = _mockRepository.StrictMock<IPageEventTrackingService>();
            _entityMapper = _mockRepository.StrictMock<IEntityMapper>();
            _trackingController = new TrackingController(_formEventTrackingService, _pageEventTrackingService, _entityMapper);
        }
コード例 #5
0
        public QueryVisitor(IEntityMapper mapper, WhereVisitor whereVisitor, ProjectorVisitor projectorVisitor)
        {
            this.mapper = mapper;

            this.whereVisitor = whereVisitor;
            this.projectorVisitor = projectorVisitor;

            //TODO: Refactoring
            this.whereVisitor.Mapper = mapper;
            this.projectorVisitor.Mapper = mapper;
        }
コード例 #6
0
        public CommandBuilder(IEntityMapper mapper)
        {
            if (mapper == null) throw new ArgumentNullException("mapper");

            _mapper = mapper;
            _tableName = mapper.TableName;
            foreach (var property in mapper.Properties.Values)
            {
                if (property.IsPrimaryKey)
                    _keys.Add(property);
                else
                    _values.Add(property);
            }
        }
コード例 #7
0
 public OrderByToken(MethodCallExpression expression,
                     IEntityMapper mapper, bool descending) : base(expression, mapper)
 {
     Descending = descending;
 }
コード例 #8
0
 public static void RegisterMapper(Type t, IEntityMapper modifications)
 {
     Registry[t] = modifications;
 }
コード例 #9
0
ファイル: DeskFinder.cs プロジェクト: maurbone/DocSuitePA
 public DeskFinder(IEntityMapper <Desk, DeskResult> mapper, string currentUserName)
     : this(System.Enum.GetName(typeof(EnvironmentDataCode), EnvironmentDataCode.ProtDB), mapper, currentUserName)
 {
     InitializeProperty();
 }
コード例 #10
0
 public DeskApprovalEndorsementFinder(string dbName, IEntityMapper <Desk, DeskEndorsement> mapper)
     : base(dbName, mapper)
 {
     VersionFilters = new Dictionary <Guid, decimal>();
 }
コード例 #11
0
ファイル: UnaryToken.cs プロジェクト: sashayudaev/Dapper.Linq
 public UnaryToken(UnaryExpression expression, IEntityMapper mapper)
     : base(expression, mapper)
 {
 }
コード例 #12
0
 public void SetUp()
 {
     _mockRepository = new MockRepository();
     _mongoDbProxy = _mockRepository.StrictMock<IMongoDbProxy>();
     _entityMapper = _mockRepository.StrictMock<IEntityMapper>();
 }
コード例 #13
0
ファイル: Query{T}.cs プロジェクト: shuhari/Shuhari.Framework
 /// <summary>
 /// Initialize
 /// </summary>
 /// <param name="session"></param>
 /// <param name="sql"></param>
 /// <param name="provided"></param>
 public Query(Session session, string sql, IEntityMapper <T> provided)
     : base(session, sql)
 {
     _mapper = EnsureMapper(provided);
 }
コード例 #14
0
        public AdventureWorksDbContext(IOptions <AppSettings> appSettings, IEntityMapper entityMapper)
        {
            ConnectionString = appSettings.Value.ConnectionString;

            EntityMapper = entityMapper;
        }
コード例 #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EfDbArgs{T, TModel}"/> class with a <paramref name="mapper"/> and <paramref name="paging"/>.
 /// </summary>
 /// <param name="mapper">The <see cref="IEntityMapper{T, TModel}"/>.</param>
 /// <param name="paging">The <see cref="PagingArgs"/>.</param>
 /// <param name="dbContext">The <see cref="Microsoft.EntityFrameworkCore.DbContext"/> where overridding automatic default.</param>
 public EfDbArgs(IEntityMapper <T, TModel> mapper, PagingArgs paging, DbContext?dbContext = null)
     : this(mapper, new PagingResult(paging ?? throw new ArgumentNullException(nameof(paging))), dbContext)
コード例 #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EfDbArgs{T, TModel}"/> class with a <paramref name="mapper"/>.
 /// </summary>
 /// <param name="mapper">The <see cref="IEntityMapper{T, TModel}"/>.</param>
 /// <param name="dbContext">The <see cref="Microsoft.EntityFrameworkCore.DbContext"/> where overridding automatic default.</param>
 public EfDbArgs(IEntityMapper <T, TModel> mapper, DbContext?dbContext = null)
 {
     Mapper    = mapper ?? throw new ArgumentNullException(nameof(mapper));
     DbContext = dbContext;
 }
コード例 #17
0
		/// <summary>
		/// Initializes a new instance of the <see cref="ControllerHandler"/> class.
		/// </summary>
		/// <param name="controllerType">Type of the controller.</param>
        protected internal ControllerHandler(Application application, ControllerDescriptor descriptor, ILogger logger)
        {
            this.descriptor = descriptor;
            this.logger = logger;
            this.application = application;

            controllerConstructor = descriptor.ControllerType.GetConstructor(Type.EmptyTypes);

            foreach (ControllerDescriptor.BindPointDescriptor bindPoint in descriptor.Targets)
                manipulatedFields.AddRange(bindPoint.ParameterFields.Values);
            manipulatedFields.AddRange(descriptor.FormFields.Values);
            manipulatedFields.AddRange(descriptor.RequestFields.Values);
            manipulatedFields.AddRange(descriptor.SessionFields.Values);
            foreach (ControllerDescriptor.CookieFieldDescriptor cookieField in descriptor.CookieFields.Values)
                manipulatedFields.Add(cookieField.Field);

            manipulatedFields.ForEach(
                (mbr) => 
                {
//                    var attributes = mbr.GetCustomAttributes(typeof(FormatAsAttribute), false) as FormatAsAttribute[];
                    var attributes = mbr.GetCustomAttributes(typeof(FormatAsAttribute), false).ToArray();
                    if (attributes.Length != 1)
                        return;

                    formatters.Add(mbr, application.FormatManagerFactory.GetManagerInstance().GetFormatterByFormat(attributes[0].Properties["FormatName"].AsString()));
                }
            );

		    var mapperAttribute = descriptor.ControllerType.GetCustomAttributes(typeof (MapsWithAttribute), false) as MapsWithAttribute[];
            if (mapperAttribute != null && mapperAttribute.Length == 1)
                mapper = Activator.CreateInstance(mapperAttribute[0].MapperType) as IEntityMapper;
        }
コード例 #18
0
 public DeskRoleUserFinder(string dbName, IEntityMapper <DeskRoleUser, DeskRoleUser> mapper)
     : base(dbName, mapper)
 {
 }
コード例 #19
0
 public EntityNavigationCollectionSerializer(string foreignKey, IEntityMapper entityMapper)
 {
     ForeignKey         = foreignKey;
     ForeignPropertyMap = entityMapper.GetEntityMapping().Where(m => m.Property.Name == foreignKey).FirstOrDefault();
     EntityMapper       = entityMapper;
 }
コード例 #20
0
 public DefaultSqlGenerater(IEntityMapper mapper, ISqlAdapter sqlAdapter)
 {
     _mapper     = mapper;
     _sqlAdapter = sqlAdapter;
 }
コード例 #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ODataArgs{T, TModel}"/> class with a <paramref name="mapper"/>.
 /// </summary>
 /// <param name="mapper">The <see cref="IEntityMapper{T, TModel}"/>.</param>
 /// <param name="collectionName">The entity collection name where overridding default.</param>
 public ODataArgs(IEntityMapper <T, TModel> mapper, string?collectionName = null)
 {
     Mapper         = Check.NotNull(mapper, nameof(mapper));
     CollectionName = collectionName;
 }
コード例 #22
0
 public PlayerGameController(PlayerGameRepository playergameRepository, IEntityMapper <PlayerGame, PlayerGameViewModel> entityToVmMapper, IEntityMapper <PlayerGameViewModel, PlayerGame> vmToEntityMapper)
 {
     this.playergameRepository = playergameRepository;
     this.entityToVmMapper     = entityToVmMapper;
     this.vmToEntityMapper     = vmToEntityMapper;
 }
コード例 #23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ODataArgs{T, TModel}"/> class.
 /// </summary>
 /// <param name="mapper">The <see cref="IEntityMapper{T, TModel}"/>.</param>
 /// <param name="paging">The <see cref="PagingResult"/>.</param>
 /// <param name="collectionName">The entity collection name where overridding default.</param>
 public ODataArgs(IEntityMapper <T, TModel> mapper, PagingResult paging, string?collectionName = null) : this(mapper, collectionName)
 {
     Paging = Check.NotNull(paging, nameof(paging));
 }
コード例 #24
0
 public AutoNewsContext(DbContextOptions <AutoNewsContext> options, IEntityMapper entityMapper) : base(options)
 {
     _EntityMapper = entityMapper;
 }
コード例 #25
0
ファイル: CrudService.cs プロジェクト: AniaDomachowska/GTDGo
 public CrudService(IBaseRepository <TEntity> baseRepository, IEntityMapper mapper)
 {
     this.baseRepository = baseRepository;
     this.mapper         = mapper;
 }
コード例 #26
0
 public DeskApprovalEndorsementFinder(IEntityMapper <Desk, DeskEndorsement> mapper)
     : this(System.Enum.GetName(typeof(EnvironmentDataCode), EnvironmentDataCode.ProtDB), mapper)
 {
 }
コード例 #27
0
 internal static string GetRelevanceAlias(IEntityMapper <T> mpper)
 {
     return(string.Join("|", from t in mpper.Relevances select t.AliaName));
 }
コード例 #28
0
 public CheckNotificationService(ISystemClock systemClock, Entities.CheckContext context, IEntityMapper entityMapper)
 {
     _systemClock  = systemClock;
     _context      = context;
     _entityMapper = entityMapper;
 }
コード例 #29
0
        /// <summary>
        /// Maps the next object from Dapper.
        /// </summary>
        /// <typeparam name="TItemType">The item type to be mapped.</typeparam>
        /// <param name="context">The context used to map object from Dapper.</param>
        /// <param name="fieldNames">The names of one or more GraphQL fields associated with the item.</param>
        /// <param name="entityMapper">An optional entity mapper.  This is used to map complex objects from Dapper mapping results.</param>
        /// <returns>The mapped item.</returns>
        public TItemType Next <TItemType>(
            IEnumerable <string> fieldNames,
            Func <IDictionary <string, Field>, IHaveSelectionSet, IHaveSelectionSet> getSelectionSet,
            IEntityMapper <TItemType> entityMapper = null)
            where TItemType : class
        {
            if (fieldNames == null)
            {
                throw new ArgumentNullException(nameof(fieldNames));
            }

            if (ItemEnumerator == null ||
                SplitOnEnumerator == null)
            {
                throw new NotSupportedException("Cannot call Next() before calling Start()");
            }

            lock (LockObject)
            {
                var keys = fieldNames.Intersect(CurrentSelectionSet.Keys);
                if (keys.Any())
                {
                    TItemType item = default(TItemType);
                    while (
                        ItemEnumerator.MoveNext() &&
                        SplitOnEnumerator.MoveNext())
                    {
                        // Whether a non-null object exists at this position or not,
                        // the SplitOn is expecting this type here, so we will yield it.
                        if (SplitOnEnumerator.Current == typeof(TItemType))
                        {
                            item = ItemEnumerator.Current as TItemType;
                            break;
                        }
                    }

                    if (entityMapper != null)
                    {
                        // Determine where the next entity mapper will get its selection set from
                        IHaveSelectionSet selectionSet = getSelectionSet(CurrentSelectionSet, SelectionSet);

                        var nextContext = new EntityMapContext
                        {
                            Items        = Items.Skip(MappedCount),
                            SelectionSet = selectionSet,
                            SplitOn      = SplitOn.Skip(MappedCount),
                        };
                        using (nextContext)
                        {
                            item = entityMapper.Map(nextContext);

                            // Update enumerators to skip past items already mapped
                            var mappedCount = nextContext.MappedCount;
                            MappedCount += nextContext.MappedCount;
                            int i = 0;
                            while (
                                // Less 1, the next time we iterate we
                                // will advance by 1 as part of the iteration.
                                i < mappedCount - 1 &&
                                ItemEnumerator.MoveNext() &&
                                SplitOnEnumerator.MoveNext())
                            {
                                i++;
                            }
                        }
                    }
                    else
                    {
                        MappedCount++;
                    }
                    return(item);
                }
            }
            return(default(TItemType));
        }
コード例 #30
0
 public ExecuteQuerySqlStatement(IStatementExecutor commandExecutor, IEntityMapper entityMapper)
     : base(commandExecutor)
 {
     this.entityMapper = entityMapper;
 }
コード例 #31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SqlClientRepository{TModel,TEntity}"/> class.
 /// </summary>
 /// <param name="repositoryProvider">
 /// The repository provider.
 /// </param>
 /// <param name="entityMapper">
 /// The entity mapper.
 /// </param>
 public SqlClientRepository(IRepositoryProvider repositoryProvider, IEntityMapper entityMapper)
     : base(repositoryProvider, entityMapper)
 {
 }
コード例 #32
0
 public OrderByToken(MethodCallExpression expression, IEntityMapper mapper)
     : this(expression, mapper, descending : false)
 {
 }
コード例 #33
0
 public PlayerController(PlayerRepository playerRepository, IEntityMapper <Player, PlayerViewModel> entityToVmMapper, IEntityMapper <PlayerViewModel, Player> vmToEntityMapper)
 {
     this.playerRepository = playerRepository;
     this.entityToVmMapper = entityToVmMapper;
     this.vmToEntityMapper = vmToEntityMapper;
 }
コード例 #34
0
 public DeskRoleUserFinder(IEntityMapper <DeskRoleUser, DeskRoleUser> mapper)
     : base(mapper)
 {
 }
コード例 #35
0
 public FormEventRepository(ISimpleDbProxy simpleDbProxy, IEntityMapper entityMapper)
 {
     _simpleDbProxy = simpleDbProxy;
     _entityMapper = entityMapper;
 }
コード例 #36
0
 protected EntityRepository(IEntityMapper <T> mapper, IDatabase database)
 {
     _mapper   = mapper;
     _database = database;
 }
コード例 #37
0
 public FormEventRepository(IMongoDbProxy mongoDbProxy, IEntityMapper entityMapper)
     : base(mongoDbProxy, entityMapper)
 {
 }
コード例 #38
0
        /// <summary>
        ///     Return an enumerable which uses lazy loading of each row.
        /// </summary>
        /// <typeparam name="TEntity">Type of entity to map</typeparam>
        /// <param name="cmd">Command to invoke <c>ExecuteReaderAsync()</c> on.</param>
        /// <param name="ownsConnection">
        ///     <c>true</c> if the connection should be disposed together with the command/datareader. See
        ///     remarks.
        /// </param>
        /// <param name="mapper">Mapper used to convert rows to entities</param>
        /// <returns>Lazy loaded enumerator</returns>
        /// <remarks>
        ///     <para>
        ///         The command is executed asynchronously.
        ///     </para>
        ///     <para>
        ///         The returned enumerator will not map each row until it's requested. To be able to do that the
        ///         connection/command/datareader is
        ///         kept open until the enumerator is disposed. Hence it's important that you make sure that the enumerator is
        ///         disposed when you are
        ///         done with it.
        ///     </para>
        ///     <para>
        ///         Requires that a <c><![CDATA[IEntityMapper<TEntity>]]></c> is registered in the
        ///         <see cref="EntityMappingProvider" />.
        ///     </para>
        /// </remarks>
        public static async Task <IEnumerable <TEntity> > ToEnumerableAsync <TEntity>(this IDbCommand cmd,
                                                                                      bool ownsConnection, IEntityMapper <TEntity> mapper)
        {
            if (cmd == null)
            {
                throw new ArgumentNullException("cmd");
            }
            if (mapper == null)
            {
                throw new ArgumentNullException("mapper");
            }

            var command = GetDbCommandFromInterface(cmd);

            try
            {
                var reader = await command.ExecuteReaderAsync();

                var mapping = EntityMappingProvider.GetBaseMapper <TEntity>();
                return(new AdoNetEntityEnumerable <TEntity>(cmd, reader, mapping, ownsConnection));
            }
            catch (Exception e)
            {
                throw command.CreateDataException(e);
            }
        }
コード例 #39
0
 protected EventRepository(IMongoDbProxy mongoDbProxy, IEntityMapper entityMapper)
 {
     MongoDbProxy = mongoDbProxy;
     EntityMapper = entityMapper;
 }
コード例 #40
0
 public GameController(GameRepository gameRepository, IEntityMapper <Game, GameViewModel> entityToVmMapper, IEntityMapper <GameViewModel, Game> vmToEntityMapper)
 {
     this.gameRepository   = gameRepository;
     this.entityToVmMapper = entityToVmMapper;
     this.vmToEntityMapper = vmToEntityMapper;
 }
コード例 #41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PostgreSqlRepository{TModel,TEntity}"/> class.
 /// </summary>
 /// <param name="repositoryProvider">
 /// The repository provider.
 /// </param>
 /// <param name="entityMapper">
 /// The entity mapper.
 /// </param>
 public PostgreSqlRepository(IRepositoryProvider repositoryProvider, IEntityMapper entityMapper)
     : base(repositoryProvider, entityMapper)
 {
 }
コード例 #42
0
 public SqliteCommandBuilder(IEntityMapper mapper) : base(mapper)
 {
 }
コード例 #43
0
 public static ICommandBuilder Create(IEntityMapper mapper)
 {
     return _commandBuilder(mapper);
 }
コード例 #44
0
 public SqlServerCommandBuilder(IEntityMapper mapper)
     : base(mapper)
 {
 }
コード例 #45
0
 public FootballDbContext(DbContextOptions <FootballDbContext> options, IEntityMapper mapper = null) : base(options)
 {
     EntityMapper = mapper;
 }