惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

I
Intezer
The Register - Security
The Register - Security
博客园 - 三生石上(FineUI控件)
博客园_首页
量子位
Hugging Face - Blog
Hugging Face - Blog
Engineering at Meta
Engineering at Meta
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Last Week in AI
Last Week in AI
博客园 - 【当耐特】
N
Netflix TechBlog - Medium
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
GbyAI
GbyAI
D
Docker
M
MIT News - Artificial intelligence
Jina AI
Jina AI
The GitHub Blog
The GitHub Blog
V
Visual Studio Blog
T
Tailwind CSS Blog
S
SegmentFault 最新的问题
Microsoft Azure Blog
Microsoft Azure Blog
G
Google Developers Blog
有赞技术团队
有赞技术团队
IT之家
IT之家
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Troy Hunt's Blog
Cyberwarzone
Cyberwarzone
Recorded Future
Recorded Future
H
Help Net Security
L
LINUX DO - 热门话题
罗磊的独立博客
Google DeepMind News
Google DeepMind News
NISL@THU
NISL@THU
SecWiki News
SecWiki News
T
Threat Research - Cisco Blogs
T
Threatpost
Cloudbric
Cloudbric
G
GRAHAM CLULEY
S
Security @ Cisco Blogs
Hacker News - Newest:
Hacker News - Newest: "LLM"
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美
P
Proofpoint News Feed
V2EX - 技术
V2EX - 技术
L
LangChain Blog
The Cloudflare Blog
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
B
Blog
T
The Blog of Author Tim Ferriss

博客园 - 问天

开发笔记1: 范型 Web安全,以新浪微博“郭美美”蠕虫为例 介绍两个Python web框架:Django & Tornado 扯一下抽象 跟赵姐夫扯 webform的设计 MoSonic:对SubSonic的分布式存储、缓存改进尝试(4) MoSonic:对SubSonic的分布式存储、缓存改进尝试(3) MoSonic:对SubSonic的分布式存储、缓存改进尝试(2) MoSonic:对SubSonic的分布式存储、缓存改进方案尝试(1) Discuz!NT在64位Windows下运行的问题 说说分页 iPhone Web App开发杂感 Katze - 简单的.net "ORM"框架 基于Gettext的asp.net网站多语言解决方案 Django on IronPython and Windows 动态修改.Net StreamReader Encoding编码 恐怖的迅雷 TinyMCE 的音乐插件/mp3 music insert plugin 微软是如何输掉API之战(下)
C#范型不会用,求助~
问天 · 2015-02-22 · via 博客园 - 问天
using Dapper;
using Dapper.Contrib.Extensions;
using System.Data.SqlClient;
using System.Configuration;

namespace Orm
{
    public class RecordBase<T> where T : class
    {

        public static SqlConnection OpenConnection()
        {
            var ConnStr = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
            SqlConnection connection = new SqlConnection(ConnStr);
            connection.Open();
            return connection;
        }

        public static T Get(string id)
        {
            using (var conn = OpenConnection())
            {
                return conn.Get<T>(id);
            }
        }

        public bool Update()
        {
            using (var conn = OpenConnection())
            {
                //Beblow compile error, because conn.Update<T> expect parameter to be T, i.e. the sub-class, but "this" is parent class.
                return conn.Update<T>(this);
            }
        }
    }
}