예제 #1
0
 public Repository()
 {
     DommelMapper.SetTableNameResolver(new DefaultTableNameResolver());
     DommelMapper.SetKeyPropertyResolver(new DefaultKeyPropertyResolver());
     DommelMapper.SetColumnNameResolver(new DefaultColumnNameResolver());
     DommelMapper.SetPropertyResolver(new DefaultPropertyResolver());
     DommelMapper.SetForeignKeyPropertyResolver(new DefaultForeignKeyPropertyResolver());
 }
 /// <summary>
 /// Configures the specified configuration for Dapper.FluentMap.Dommel.
 /// </summary>
 /// <param name="config">The Dapper.FluentMap configuration.</param>
 /// <returns>The Dapper.FluentMap configuration.</returns>
 public static FluentMapConfiguration ForDommel(this FluentMapConfiguration config)
 {
     DommelMapper.SetColumnNameResolver(new DommelColumnNameResolver());
     DommelMapper.SetKeyPropertyResolver(new DommelKeyPropertyResolver());
     DommelMapper.SetTableNameResolver(new DommelTableNameResolver());
     DommelMapper.SetPropertyResolver(new DommelPropertyResolver());
     return(config);
 }
예제 #3
0
 public RuntimeInitializer DefaultMapper(Type type)
 {
     DapperExtensions.DapperExtensions.DefaultMapper = type;
     DommelMapper.SetTableNameResolver(new TableNameResolver());
     DommelMapper.SetKeyPropertyResolver(new KeyPropertyResolver());
     DommelMapper.SetColumnNameResolver(new ColumnNameResolver());
     return(this);
 }
예제 #4
0
 private void InitializeEntityMappings()
 {
     FluentMapper.Initialize(config =>
     {
         config.ForDommel();
         DommelMapper.SetKeyPropertyResolver(new PrimaryKeyResolver());
         DommelMapper.SetTableNameResolver(new TableNameResolver());
     });
 }
예제 #5
0
        public long GetList_Count(Expression <Func <T, bool> > filter = null)
        {
            _tableName = typeof(T).Name;

            using (var connection = CreateConnection())
            {
                DommelMapper.SetTableNameResolver(new CustomTableNameResolver());

                return(filter == null
                    ? connection.QueryFirstOrDefault <long>($"SELECT COUNT(1) FROM {_tableName}")
                    : connection.Count <T>(filter));
            }
        }
예제 #6
0
        public IEnumerable <T> GetList(Expression <Func <T, bool> > filter = null)
        {
            _tableName = typeof(T).Name;

            using (var connection = CreateConnection())
            {
                DommelMapper.SetTableNameResolver(new CustomTableNameResolver());

                return(filter == null
                    ? connection.Query <T>($"SELECT * FROM {_tableName}")
                    : connection.Select(filter));
            }
        }
예제 #7
0
 public static void Configure()
 {
     DommelMapper.SetTableNameResolver(new UnderscoreTableNameResolver());
     DommelMapper.SetColumnNameResolver(new UnderscoreColumnNameResolver());
     DefaultTypeMap.MatchNamesWithUnderscores = true;
 }
예제 #8
0
 public Startup(IConfiguration configuration)
 {
     DommelMapper.SetTableNameResolver(new DommelTableNameResolver());
     Configuration = configuration;
     StaticConfig  = configuration;
 }
예제 #9
0
 public Startup(IConfiguration configuration)
 {
     this.Configuration = configuration;
     DommelMapper.SetTableNameResolver(new CustomTableNameResolver());
 }
예제 #10
0
 /// <summary>
 /// 自定义相关解析注入
 /// </summary>
 static DapperExtensions()
 {
     DommelMapper.SetTableNameResolver(new CustomTableNameResolver());     //TableName
     DommelMapper.SetKeyPropertyResolver(new CustomKeyPropertyResolver()); //Key
 }