Skip to content

Instantly share code, notes, and snippets.

Dhananjay Kumar debugmodedotnet

Block or report user

Report or block debugmodedotnet

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View typescriptinsublimetext2.ts
class Student {
name: string;
age: number;
constructor(name: string, age: number) {
this.name = name;
this.age = age;
}
Print() {
View codefirstdemo1.cs
namespace CodeFirstDemoApp
{
public class Student
{
public int Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
}
View codefirstdemo2.cs
using System.Data.Entity;
namespace CodeFirstDemoApp
{
public class Context : DbContext
{
public Context() : base()
{
}
public DbSet<Student> Students { get; set; }
View codefirstdemo3.cs
using System;
using System.Linq;
namespace CodeFirstDemoApp
{
class Program
{
static void Main(string[] args)
{
CreateStudent();
View codefirstdemo5.cs
public class StudentAccount
{
public int Id { get; set; }
public string Name { get; set; }
public int Amount { get; set; }
[Required]
public virtual Student Student { get; set; }
View codefirstdemo4.cs
public class Student
{
public int Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
public virtual StudentAccount StudentAccount { get; set; }
View codefirstdemo6.cs
using System.Data.Entity;
namespace CodeFirstDemoApp
{
public class Context : DbContext
{
public Context()
: base("name=democonnectionstring")
{
View codefirstdemo7.cs
static void CreateStudent()
{
Student s = new Student
{
Id = 1,
Age = 12,
Name = "Foo"
};
StudentAccount sa = new StudentAccount
{
View codefirstdemo8.cs
Context c = new Context();
var result = from r in c.Students select r;
foreach (var r in result)
{
Console.WriteLine(r.Name);
Console.WriteLine(r.StudentAccounts.Amount);
}
View codefirstdemo9.cs
public class Student
{
public Student()
{
StudentAddresses = new HashSet<StudentAddress>();
}
public int Id { get; set; }
public string Name { get; set; }
You can’t perform that action at this time.