c# - Spring.NET 等效于 Java Spring 数据访问用法

标签 c# java spring spring.net data-access

Spring.NET 中“SimpleJdbcCall”、“MapSqlParameterSource”和“BeanPropertySqlParameterSource”的等效项是什么?如何在Spring.NET中编写下面的Java:

publicvoid create(T object) {
if(object==null)
return null;
SimpleJdbcCall pspCreate = new SimpleJdbcCall(jdbcTemplate).withProcedureName("cr eate_sp").withReturnValue().declareParameters(new SqlOutParameter("id", Types.BIGINT));
SqlParameterSource in = new BeanPropertySqlParameterSource(object);
Map<String, Object> m = pspCreate.execute(in);
long id = m.containsKey(IDENTITY_VALUE)?(Long) m.get(IDENTITY_VALUE):0;
int resultCode =m.containsKey(RETURN_VALUE)?(Integer) m.get(RETURN_VALUE):0;
}


public List<T> retrieveAll(int pageNum, int pageSize) {
SqlParameterSource in = new MapSqlParameterSource()
.addValue("pageNum", pageNum, Types.INTEGER)
.addValue("pageSize", pageSize, Types.INTEGER);

SimpleJdbcCall pspRetrieveAll =new SimpleJdbcCall(jdbcTemplate).withProcedureName("re trieve_all_sp").withReturnValue().returningResultS et("LIST", BeanPropertyRowMapper.newInstance(UploadBatch.clas s)).returningResultSet(NO_OF_RECORDS, new RowMapper<Long>() {

@Override
public Long mapRow(ResultSet rs, int rowNum) throws SQLException {
return rs.getLong(1);
}
});
Map<String, Object> m = pspRetrieveAll.execute(in);
List<T> list=null;
if(m.containsKey(LIST))
list = (List<T>) m.get(LIST);

return list;
} 

最佳答案

关于c# - Spring.NET 等效于 Java Spring 数据访问用法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13237529/

相关文章:

java - 存在循环 bean 依赖时 Spring Bean 创建的随机性

java - 上下文是只读的

c# - Visual Studio MEF 扩展 - 强制更新或重绘边距字形

java - 返回参数的数据类型

c# - 从 services.msc c# 获取服务路径

java - 使用 to-date 函数更新 jdbc 中的 Date_n

java - 字符串版本比较

java - 目标org.springframework.boot的执行默认值:spring-boot-maven-plugin:1. 4.0.RELEASE:repackage failed: Unable to rename

c# - DiagnosticDescriptor 构造函数的新参数的相关性?

c# - WPF 本地化扩展 : Translate window at run-time