Skip to content

Instantly share code, notes, and snippets.

View debugmodedotnet's full-sized avatar

Dhananjay Kumar debugmodedotnet

View GitHub Profile
class Student {
name: string;
age: number;
constructor(name: string, age: number) {
this.name = name;
this.age = age;
}
Print() {
namespace CodeFirstDemoApp
{
public class Student
{
public int Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
}
using System.Data.Entity;
namespace CodeFirstDemoApp
{
public class Context : DbContext
{
public Context() : base()
{
}
public DbSet<Student> Students { get; set; }
using System;
using System.Linq;
namespace CodeFirstDemoApp
{
class Program
{
static void Main(string[] args)
{
CreateStudent();
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; }
public class Student
{
public int Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
public virtual StudentAccount StudentAccount { get; set; }
using System.Data.Entity;
namespace CodeFirstDemoApp
{
public class Context : DbContext
{
public Context()
: base("name=democonnectionstring")
{
static void CreateStudent()
{
Student s = new Student
{
Id = 1,
Age = 12,
Name = "Foo"
};
StudentAccount sa = new StudentAccount
{
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);
}
public class Student
{
public Student()
{
StudentAddresses = new HashSet<StudentAddress>();
}
public int Id { get; set; }
public string Name { get; set; }