Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
NPoco
提交
69bcb39c
N
NPoco
项目概览
jobily
/
NPoco
9 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
NPoco
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
69bcb39c
编写于
3月 16, 2014
作者:
A
Adam Schroder
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow ResultColumns to be optionally included in auto generated select sql
上级
50f0109a
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
33 addition
and
3 deletion
+33
-3
src/NPoco/ColumnInfo.cs
src/NPoco/ColumnInfo.cs
+14
-1
src/NPoco/FluentMappings/ColumnConfigurationBuilder.cs
src/NPoco/FluentMappings/ColumnConfigurationBuilder.cs
+9
-0
src/NPoco/FluentMappings/ColumnDefinition.cs
src/NPoco/FluentMappings/ColumnDefinition.cs
+1
-0
src/NPoco/FluentMappings/FluentMappingConfiguration.cs
src/NPoco/FluentMappings/FluentMappingConfiguration.cs
+1
-0
src/NPoco/FluentMappings/FluentMappingsPocoData.cs
src/NPoco/FluentMappings/FluentMappingsPocoData.cs
+3
-1
src/NPoco/PocoColumn.cs
src/NPoco/PocoColumn.cs
+2
-0
src/NPoco/PocoData.cs
src/NPoco/PocoData.cs
+2
-1
src/NPoco/ResultColumnAttribute.cs
src/NPoco/ResultColumnAttribute.cs
+1
-0
未找到文件。
src/NPoco/ColumnInfo.cs
浏览文件 @
69bcb39c
...
@@ -13,6 +13,12 @@ public class ColumnInfo
...
@@ -13,6 +13,12 @@ public class ColumnInfo
public
bool
IgnoreColumn
{
get
;
set
;
}
public
bool
IgnoreColumn
{
get
;
set
;
}
public
bool
ForceToUtc
{
get
;
set
;
}
public
bool
ForceToUtc
{
get
;
set
;
}
public
Type
ColumnType
{
get
;
set
;
}
public
Type
ColumnType
{
get
;
set
;
}
public
bool
IncludeColumnInAutoQuery
{
get
;
set
;
}
public
ColumnInfo
()
{
IncludeColumnInAutoQuery
=
true
;
}
public
static
ColumnInfo
FromMemberInfo
(
MemberInfo
mi
)
public
static
ColumnInfo
FromMemberInfo
(
MemberInfo
mi
)
{
{
...
@@ -33,6 +39,7 @@ public static ColumnInfo FromMemberInfo(MemberInfo mi)
...
@@ -33,6 +39,7 @@ public static ColumnInfo FromMemberInfo(MemberInfo mi)
{
{
ci
.
IgnoreColumn
=
true
;
ci
.
IgnoreColumn
=
true
;
}
}
ci
.
IncludeColumnInAutoQuery
=
true
;
// Read attribute
// Read attribute
if
(
colAttrs
.
Any
())
if
(
colAttrs
.
Any
())
...
@@ -40,7 +47,13 @@ public static ColumnInfo FromMemberInfo(MemberInfo mi)
...
@@ -40,7 +47,13 @@ public static ColumnInfo FromMemberInfo(MemberInfo mi)
var
colattr
=
colAttrs
.
First
();
var
colattr
=
colAttrs
.
First
();
ci
.
ColumnName
=
colattr
.
Name
??
mi
.
Name
;
ci
.
ColumnName
=
colattr
.
Name
??
mi
.
Name
;
ci
.
ForceToUtc
=
colattr
.
ForceToUtc
;
ci
.
ForceToUtc
=
colattr
.
ForceToUtc
;
ci
.
ResultColumn
=
colattr
is
ResultColumnAttribute
;
var
resultColumnAttr
=
colattr
as
ResultColumnAttribute
;
if
(
resultColumnAttr
!=
null
)
{
ci
.
ResultColumn
=
true
;
ci
.
IncludeColumnInAutoQuery
=
resultColumnAttr
.
IncludeInAutoSelect
;
}
}
}
else
else
{
{
...
...
src/NPoco/FluentMappings/ColumnConfigurationBuilder.cs
浏览文件 @
69bcb39c
...
@@ -32,6 +32,7 @@ public interface IColumnBuilder
...
@@ -32,6 +32,7 @@ public interface IColumnBuilder
IColumnBuilder
Version
();
IColumnBuilder
Version
();
IColumnBuilder
Ignore
();
IColumnBuilder
Ignore
();
IColumnBuilder
Result
();
IColumnBuilder
Result
();
IColumnBuilder
Result
(
bool
includeInAutoQuery
);
}
}
public
class
ColumnBuilder
:
IColumnBuilder
public
class
ColumnBuilder
:
IColumnBuilder
...
@@ -74,6 +75,14 @@ public IColumnBuilder Ignore()
...
@@ -74,6 +75,14 @@ public IColumnBuilder Ignore()
public
IColumnBuilder
Result
()
public
IColumnBuilder
Result
()
{
{
_columnDefinition
.
IncludeInAutoQuery
=
false
;
_columnDefinition
.
ResultColumn
=
true
;
return
this
;
}
public
IColumnBuilder
Result
(
bool
includeInAutoQuery
)
{
_columnDefinition
.
IncludeInAutoQuery
=
includeInAutoQuery
;
_columnDefinition
.
ResultColumn
=
true
;
_columnDefinition
.
ResultColumn
=
true
;
return
this
;
return
this
;
}
}
...
...
src/NPoco/FluentMappings/ColumnDefinition.cs
浏览文件 @
69bcb39c
...
@@ -12,5 +12,6 @@ public class ColumnDefinition
...
@@ -12,5 +12,6 @@ public class ColumnDefinition
public
bool
?
IgnoreColumn
{
get
;
set
;
}
public
bool
?
IgnoreColumn
{
get
;
set
;
}
public
bool
?
VersionColumn
{
get
;
set
;
}
public
bool
?
VersionColumn
{
get
;
set
;
}
public
bool
?
ForceUtc
{
get
;
set
;
}
public
bool
?
ForceUtc
{
get
;
set
;
}
public
bool
?
IncludeInAutoQuery
{
get
;
set
;
}
}
}
}
}
\ No newline at end of file
src/NPoco/FluentMappings/FluentMappingConfiguration.cs
浏览文件 @
69bcb39c
...
@@ -142,6 +142,7 @@ private static void MergeOverrides(Dictionary<Type, TypeDefinition> config, Mapp
...
@@ -142,6 +142,7 @@ private static void MergeOverrides(Dictionary<Type, TypeDefinition> config, Mapp
convColDefinition
.
VersionColumn
=
overrideColumnDefinition
.
Value
.
VersionColumn
??
convColDefinition
.
VersionColumn
;
convColDefinition
.
VersionColumn
=
overrideColumnDefinition
.
Value
.
VersionColumn
??
convColDefinition
.
VersionColumn
;
convColDefinition
.
MemberInfo
=
overrideColumnDefinition
.
Value
.
MemberInfo
??
convColDefinition
.
MemberInfo
;
convColDefinition
.
MemberInfo
=
overrideColumnDefinition
.
Value
.
MemberInfo
??
convColDefinition
.
MemberInfo
;
convColDefinition
.
ForceUtc
=
overrideColumnDefinition
.
Value
.
ForceUtc
??
convColDefinition
.
ForceUtc
;
convColDefinition
.
ForceUtc
=
overrideColumnDefinition
.
Value
.
ForceUtc
??
convColDefinition
.
ForceUtc
;
convColDefinition
.
IncludeInAutoQuery
=
overrideColumnDefinition
.
Value
.
IncludeInAutoQuery
??
convColDefinition
.
IncludeInAutoQuery
;
}
}
}
}
}
}
...
...
src/NPoco/FluentMappings/FluentMappingsPocoData.cs
浏览文件 @
69bcb39c
...
@@ -66,6 +66,8 @@ public FluentMappingsPocoData(Type t, TypeDefinition typeConfig, IMapper mapper)
...
@@ -66,6 +66,8 @@ public FluentMappingsPocoData(Type t, TypeDefinition typeConfig, IMapper mapper)
if
(
colattr
.
ForceUtc
.
HasValue
&&
colattr
.
ForceUtc
.
Value
)
if
(
colattr
.
ForceUtc
.
HasValue
&&
colattr
.
ForceUtc
.
Value
)
pc
.
ForceToUtc
=
true
;
pc
.
ForceToUtc
=
true
;
if
(
colattr
.
IncludeInAutoQuery
.
HasValue
&&
colattr
.
IncludeInAutoQuery
.
Value
)
pc
.
IncludeInAutoQuery
=
true
;
for
(
int
i
=
0
;
i
<
originalPK
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
originalPK
.
Length
;
i
++)
{
{
...
@@ -92,7 +94,7 @@ public FluentMappingsPocoData(Type t, TypeDefinition typeConfig, IMapper mapper)
...
@@ -92,7 +94,7 @@ public FluentMappingsPocoData(Type t, TypeDefinition typeConfig, IMapper mapper)
TableInfo
.
PrimaryKey
=
String
.
Join
(
","
,
originalPK
);
TableInfo
.
PrimaryKey
=
String
.
Join
(
","
,
originalPK
);
// Build column list for automatic select
// Build column list for automatic select
QueryColumns
=
Columns
.
Where
(
x
=>
!
x
.
Value
.
ResultColumn
).
ToArray
();
QueryColumns
=
Columns
.
Where
(
x
=>
x
.
Value
.
IncludeInAutoQuery
).
ToArray
();
}
}
}
}
...
...
src/NPoco/PocoColumn.cs
浏览文件 @
69bcb39c
...
@@ -8,6 +8,7 @@ public class PocoColumn
...
@@ -8,6 +8,7 @@ public class PocoColumn
public
PocoColumn
()
public
PocoColumn
()
{
{
ForceToUtc
=
true
;
ForceToUtc
=
true
;
IncludeInAutoQuery
=
true
;
}
}
public
TableInfo
TableInfo
;
public
TableInfo
TableInfo
;
...
@@ -24,6 +25,7 @@ public Type ColumnType
...
@@ -24,6 +25,7 @@ public Type ColumnType
public
bool
ForceToUtc
{
get
;
set
;
}
public
bool
ForceToUtc
{
get
;
set
;
}
public
string
AutoAlias
{
get
;
set
;
}
public
string
AutoAlias
{
get
;
set
;
}
public
bool
IncludeInAutoQuery
{
get
;
set
;
}
public
virtual
void
SetValue
(
object
target
,
object
val
)
{
MemberInfo
.
SetMemberInfoValue
(
target
,
val
);
}
public
virtual
void
SetValue
(
object
target
,
object
val
)
{
MemberInfo
.
SetMemberInfoValue
(
target
,
val
);
}
public
virtual
object
GetValue
(
object
target
)
{
return
MemberInfo
.
GetMemberInfoValue
(
target
);
}
public
virtual
object
GetValue
(
object
target
)
{
return
MemberInfo
.
GetMemberInfoValue
(
target
);
}
...
...
src/NPoco/PocoData.cs
浏览文件 @
69bcb39c
...
@@ -60,6 +60,7 @@ public PocoData(Type t, IMapper mapper) : this()
...
@@ -60,6 +60,7 @@ public PocoData(Type t, IMapper mapper) : this()
pc
.
ResultColumn
=
ci
.
ResultColumn
;
pc
.
ResultColumn
=
ci
.
ResultColumn
;
pc
.
ForceToUtc
=
ci
.
ForceToUtc
;
pc
.
ForceToUtc
=
ci
.
ForceToUtc
;
pc
.
ColumnType
=
ci
.
ColumnType
;
pc
.
ColumnType
=
ci
.
ColumnType
;
pc
.
IncludeInAutoQuery
=
ci
.
IncludeColumnInAutoQuery
;
if
(
Mapper
!=
null
&&
!
Mapper
.
MapMemberToColumn
(
mi
,
ref
pc
.
ColumnName
,
ref
pc
.
ResultColumn
))
if
(
Mapper
!=
null
&&
!
Mapper
.
MapMemberToColumn
(
mi
,
ref
pc
.
ColumnName
,
ref
pc
.
ResultColumn
))
continue
;
continue
;
...
@@ -71,7 +72,7 @@ public PocoData(Type t, IMapper mapper) : this()
...
@@ -71,7 +72,7 @@ public PocoData(Type t, IMapper mapper) : this()
}
}
// Build column list for automatic select
// Build column list for automatic select
QueryColumns
=
Columns
.
Where
(
c
=>
!
c
.
Value
.
ResultColumn
).
ToArray
();
QueryColumns
=
Columns
.
Where
(
c
=>
c
.
Value
.
IncludeInAutoQuery
).
ToArray
();
}
}
protected
string
CreateAlias
(
string
typeName
,
Type
typeIn
)
protected
string
CreateAlias
(
string
typeName
,
Type
typeIn
)
...
...
src/NPoco/ResultColumnAttribute.cs
浏览文件 @
69bcb39c
...
@@ -5,6 +5,7 @@ namespace NPoco
...
@@ -5,6 +5,7 @@ namespace NPoco
[
AttributeUsage
(
AttributeTargets
.
Property
|
AttributeTargets
.
Field
)]
[
AttributeUsage
(
AttributeTargets
.
Property
|
AttributeTargets
.
Field
)]
public
class
ResultColumnAttribute
:
ColumnAttribute
public
class
ResultColumnAttribute
:
ColumnAttribute
{
{
public
bool
IncludeInAutoSelect
{
get
;
set
;
}
public
ResultColumnAttribute
()
{
}
public
ResultColumnAttribute
()
{
}
public
ResultColumnAttribute
(
string
name
)
:
base
(
name
)
{
}
public
ResultColumnAttribute
(
string
name
)
:
base
(
name
)
{
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录