개정판 e8b34346
issue #0000
ID2 Proejct.DB 없을 경우 오류처리
Change-Id: I35ea394bb25319912728e1a33fc1a36bb65e4867
ID2.Manager/ID2.Manager.Dapper/Repository/BaseRepository.cs | ||
---|---|---|
18 | 18 |
protected readonly IDbConnection _DbConnection; |
19 | 19 |
protected IDbTransaction _DbTransaction = null; |
20 | 20 |
|
21 |
protected BaseRepository(string connectionStr) |
|
22 |
{ |
|
23 |
this._DbConnection = this.DBConnection(connectionStr); |
|
24 |
|
|
25 |
SqlMapper.TypeMapProvider = type => |
|
26 |
{ |
|
27 |
// create fallback default type map |
|
28 |
var fallback = new DefaultTypeMap(type); |
|
29 |
return new CustomPropertyTypeMap(type, (t, column) => |
|
30 |
{ |
|
31 |
var property = t.GetProperties().FirstOrDefault(prop => |
|
32 |
prop.GetCustomAttributes(typeof(ColumnAttribute), true) |
|
33 |
.Cast<ColumnAttribute>() |
|
34 |
.Any(attr => attr.Name == column)); |
|
35 |
|
|
36 |
// if no property matched - fall back to default type map |
|
37 |
if (property == null) |
|
38 |
{ |
|
39 |
property = fallback.GetMember(column)?.Property; |
|
40 |
} |
|
41 |
|
|
42 |
return property; |
|
43 |
}); |
|
44 |
}; |
|
45 |
} |
|
21 |
protected BaseRepository(string connectionStr) : this(connectionStr, DatabaseType.MSSQL) { } |
|
46 | 22 |
|
47 | 23 |
protected BaseRepository(string connectionStr, DatabaseType dbType) |
48 | 24 |
{ |
... | ... | |
86 | 62 |
|
87 | 63 |
public SQLiteConnection SQLiteDBConnection(string connectionStr) |
88 | 64 |
{ |
89 |
if (System.IO.Directory.Exists(connectionStr)) |
|
90 |
{ |
|
91 |
throw new Exception("ID2 db file does not exist."); |
|
92 |
} |
|
93 |
|
|
94 | 65 |
return new SQLiteConnection(connectionStr, true); |
95 | 66 |
} |
96 | 67 |
|
내보내기 Unified diff