zoukankan      html  css  js  c++  java
  • DataContext与实体类

    // Define entity classes
    [Table(Name = "CAR")]
    public class CARclass
    {
        [Column(Name = "Id")]
        public int Id { get; set; }
        [Column(Name = "Model")]
        public string Model { get; set; }
    }
    
    // Strongly typed DataContext
    public partial class NorthWindDataContext : DataContext
    {
        public Table<CARclass> CARs;
        public NorthWindDataContext(IDbConnection connection) : base(connection) { }
        public NorthWindDataContext(string connection) : base(connection) { }
    }
    
    static void Main(string[] args)
    {
        NorthWindDataContext NWDC = new NorthWindDataContext(@"connection string");
        var NWCustomers = from NWs in NWDC.CARs
                            where NWs.Id == 1
                            select NWs;
        foreach (var cst in NWCustomers.ToList())
        {
            Console.WriteLine("Id = {0}, Model = {1}", cst.Id, cst.Model);
        }
    
        Console.ReadKey();
    }
  • 相关阅读:
    DOM编程
    BOM编程
    JavaScript
    CSS
    HTML入门
    shiro与项目集成开发
    shiro授权测试
    散列算法
    shiro认证流程
    spring boot 入门及示例
  • 原文地址:https://www.cnblogs.com/jizhiqiliao/p/10736098.html
Copyright © 2011-2022 走看看