本文整理汇总了C#中IGenericRepository.Add方法的典型用法代码示例。如果您正苦于以下问题:C# IGenericRepository.Add方法的具体用法?C# IGenericRepository.Add怎么用?C# IGenericRepository.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGenericRepository
的用法示例。
在下文中一共展示了IGenericRepository.Add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
public void Initialize()
{
users = new GenericRepository<User>(new FakeStorageContext<User>());
roles = new FakeRoles();
webSecurity = new FakeWebSecurity(roles, users);
controller = new UsersController(users, roles, webSecurity);
users.Add(new User()
{
ID = 1,
username = "Administrator",
realName = "Administrator"
});
users.Add(new User()
{
ID = 2,
username = "Advisor",
realName = "Advisor"
});
}
示例2: Initialize
public void Initialize()
{
electiveLists = new GenericRepository<ElectiveList>(new FakeStorageContext<ElectiveList>());
courses = new GenericRepository<Course>(new FakeStorageContext<Course>());
electiveListCourses = new GenericRepository<ElectiveListCourse>(new FakeStorageContext<ElectiveListCourse>());
controller = new ElectiveListsController(electiveLists, courses, electiveListCourses);
courses.Add(new Course(){
ID = 1,
coursePrefix = "AAA",
courseNumber = 123,
courseTitle = "Test Course 1",
courseDescription = "This is a test course for the testing framework.",
minHours = 3,
maxHours = 4,
undergrad = true,
variable = false,
electiveLists = new List<ElectiveListCourse>(),
});
courses.Add(new Course()
{
ID = 2,
coursePrefix = "BBB",
courseNumber = 456,
courseTitle = "Test Course 2",
courseDescription = "This is a test course for the testing framework.",
minHours = 5,
maxHours = 6,
graduate = true,
variable = false,
electiveLists = new List<ElectiveListCourse>()
});
courses.Add(new Course(){
ID = 3,
coursePrefix = "AAA",
courseNumber = 122,
courseTitle = "Test Course 3",
courseDescription = "This is a test course for the testing framework.",
minHours = 7,
maxHours = 8,
undergrad = true,
variable = true,
electiveLists = new List<ElectiveListCourse>()
});
electiveLists.Add(new ElectiveList()
{
ID = 1,
electiveListName = "Elective List 1",
courses = new List<ElectiveListCourse>(),
});
electiveLists.Add(new ElectiveList()
{
ID = 2,
electiveListName = "Elective List 2",
courses = new List<ElectiveListCourse>(),
});
electiveListCourses.Add(new ElectiveListCourse()
{
ID = 1,
electiveListID = 1,
courseID = 1,
course = courses.Find(1),
});
electiveListCourses.Add(new ElectiveListCourse()
{
ID = 2,
electiveListID = 1,
courseID = 2,
course = courses.Find(2),
});
electiveListCourses.Add(new ElectiveListCourse()
{
ID = 3,
electiveListID = 3,
courseID = 3,
course = courses.Find(3),
});
electiveLists.Find(1).courses.Add(electiveListCourses.Find(1));
electiveLists.Find(1).courses.Add(electiveListCourses.Find(2));
electiveLists.Find(2).courses.Add(electiveListCourses.Find(3));
courses.Find(1).electiveLists.Add(electiveListCourses.Find(1));
courses.Find(2).electiveLists.Add(electiveListCourses.Find(2));
courses.Find(3).electiveLists.Add(electiveListCourses.Find(3));
}
示例3: Initialize
public void Initialize()
{
plans = new GenericRepository<Plan>(new FakeStorageContext<Plan>());
planCourses = new GenericRepository<PlanCourse>(new FakeStorageContext<PlanCourse>());
semesters = new GenericRepository<Semester>(new FakeStorageContext<Semester>());
users = new GenericRepository<User>(new FakeStorageContext<User>());
degreePrograms = new GenericRepository<DegreeProgram>(new FakeStorageContext<DegreeProgram>());
roles = new FakeRoles();
webSecurity = new FakeWebSecurity(roles, users);
controller = new PlansController(plans, planCourses, semesters, users, degreePrograms, roles, webSecurity);
degreePrograms.Add(new DegreeProgram()
{
ID = 1,
degreeProgramName = "Degree Program 1"
});
degreePrograms.Add(new DegreeProgram()
{
ID = 2,
degreeProgramName = "Degree Program 2"
});
users.Add(new User()
{
ID = 1,
username = "testUser1",
realName = "Test User 1"
});
users.Add(new User()
{
ID = 2,
username = "testUser2",
realName = "Test User 2"
});
users.Add(new User()
{
ID = 3,
username = "Administrator",
realName = "Administrator"
});
users.Add(new User()
{
ID = 4,
username = "Advisor",
realName = "Advisor"
});
semesters.Add(new Semester()
{
ID = 1,
semesterTitle = "Fall",
semesterYear = 2013,
standard = true
});
semesters.Add(new Semester()
{
ID = 2,
semesterTitle = "Spring",
semesterYear = 2014,
standard = true
});
plans.Add(new Plan()
{
ID = 1,
planName = "Plan 1",
degreeProgramID = 1,
degreeProgram = degreePrograms.Find(1),
userID = 1,
//user = users.Find(1),
semesterID = 1,
semester = semesters.Find(1),
planCourses = new Collection<PlanCourse>()
});
plans.Add(new Plan()
{
ID = 2,
planName = "Plan 2",
degreeProgramID = 2,
degreeProgram = degreePrograms.Find(2),
userID = 2,
//user = users.Find(2),
semesterID = 2,
semester = semesters.Find(2),
planCourses = new Collection<PlanCourse>()
});
}
示例4: Initialize
public void Initialize()
{
degreePrograms = new GenericRepository<DegreeProgram>(new FakeStorageContext<DegreeProgram>());
requiredCourses = new GenericRepository<RequiredCourse>(new FakeStorageContext<RequiredCourse>());
electiveCourses = new GenericRepository<ElectiveCourse>(new FakeStorageContext<ElectiveCourse>());
electiveLists = new GenericRepository<ElectiveList>(new FakeStorageContext<ElectiveList>());
courses = new GenericRepository<Course>(new FakeStorageContext<Course>());
controller = new DegreeProgramsController(degreePrograms, requiredCourses, electiveCourses, electiveLists, courses);
courses.Add(new Course()
{
ID = 1,
coursePrefix = "AAA",
courseNumber = 123,
courseTitle = "Test Course 1",
courseDescription = "This is a test course for the testing framework.",
minHours = 3,
maxHours = 4,
undergrad = true,
variable = false,
});
courses.Add(new Course()
{
ID = 2,
coursePrefix = "BBB",
courseNumber = 456,
courseTitle = "Test Course 2",
courseDescription = "This is a test course for the testing framework.",
minHours = 5,
maxHours = 6,
graduate = true,
variable = false,
});
courses.Add(new Course()
{
ID = 3,
coursePrefix = "AAA",
courseNumber = 122,
courseTitle = "Test Course 3",
courseDescription = "This is a test course for the testing framework.",
minHours = 7,
maxHours = 8,
undergrad = true,
variable = true,
});
electiveLists.Add(new ElectiveList()
{
ID = 1,
electiveListName = "Elective List 1",
});
electiveLists.Add(new ElectiveList()
{
ID = 2,
electiveListName = "Elective List 2",
});
degreePrograms.Add(new DegreeProgram()
{
ID = 1,
degreeProgramName = "Degree Program 1",
requiredCourses = new Collection<RequiredCourse>(),
electiveCourses = new Collection<ElectiveCourse>(),
});
degreePrograms.Add(new DegreeProgram()
{
ID = 2,
degreeProgramName = "Degree Program 2",
requiredCourses = new Collection<RequiredCourse>(),
electiveCourses = new Collection<ElectiveCourse>(),
});
requiredCourses.Add(new RequiredCourse()
{
ID = 1,
courseID = 1,
course = courses.Find(1),
degreeProgramID = 1,
semester = 3,
});
requiredCourses.Add(new RequiredCourse()
{
ID = 2,
courseID = 2,
course = courses.Find(2),
degreeProgramID = 1,
semester = 2,
});
requiredCourses.Add(new RequiredCourse()
{
ID = 3,
courseID = 3,
course = courses.Find(3),
degreeProgramID = 1,
semester = 1,
});
degreePrograms.Find(1).requiredCourses.Add(requiredCourses.Find(1));
degreePrograms.Find(1).requiredCourses.Add(requiredCourses.Find(2));
//.........这里部分代码省略.........
示例5: ImportGirlsToDatabase
private static void ImportGirlsToDatabase(IEnumerable<Girl> list, IGenericRepository<Girl> sqlRepo)
{
foreach (var girl in list)
{
sqlRepo.Add(girl);
}
sqlRepo.SaveChanges();
}
示例6: ImportCustomersToDatabase
private static void ImportCustomersToDatabase(IEnumerable<Customer> list, IGenericRepository<Customer> repo)
{
foreach (var customer in list)
{
repo.Add(customer);
// mySqlRepo.Add(customer);
}
repo.SaveChanges();
// mySqlRepo.SaveChanges();
}