linux db2创建存储过程语法,EF基础一-db2存储过程中循环语句while do...-oracle 创建DBLINK_169IT.COM...

EF基础,从0开始:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Data.Entity;

using System.ComponentModel.DataAnnotations;

namespace CodeFirstNewDatabase

{

class Program

{

static void Main(string[] args)

{

using (var db = new BloggingContext())

{

Console.Write("Enter a name for a new Blog: ");

var name = Console.ReadLine();

var blog = new Blog { Name = name };

db.Blogs.Add(blog);

db.SaveChanges();

var query = from b in db.Blogs

orderby b.Name

select b;

Console.WriteLine("All blogs in the database:");

foreach (var item in query)

{

Console.WriteLine(item.Name);

}

Console.WriteLine("Press any key to exit...");

Console.ReadKey();

}

}

}

public class Blog

{

public int BlogID { get; set; }

public string Name { get; set; }

public string Url { get; set; }

public virtual IList Posts { get; set; }

}

public class Post

{

public int PostID { get; set; }

public string Title { get; set; }

public string Content { get; set; }

public int BlogId { get; set; }

public virtual Blog Blog { get; set; }

}

public class User

{

[Key] // annotation: keyattribute

public string Username { get; set; }

public string Displayname { get; set; }

}

public class BloggingContext : DbContext

{

public DbSet Blogs { get; set; }

public DbSet Posts { get; set; }

public DbSet Users { get; set; }

protected override void OnModelCreating(DbModelBuilder modelBuilder) // fluent api: override onmodelcreating method

{

modelBuilder.Entity()

.Property(u => u.Displayname)

.HasColumnName("Display_name");

}

}

}

作者:incognito007 发表于2013-3-14 10:09:35 原文链接

阅读:49 评论:0 查看评论

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值