本文整理汇总了C#中eSARDAL.DCFIEntities.Entry方法的典型用法代码示例。如果您正苦于以下问题:C# DCFIEntities.Entry方法的具体用法?C# DCFIEntities.Entry怎么用?C# DCFIEntities.Entry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eSARDAL.DCFIEntities
的用法示例。
在下文中一共展示了DCFIEntities.Entry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DismissStudent
public Boolean DismissStudent(string studentID, ref string message)
{
message = "Student dismissed successfully.";
Boolean ret = true;
using (var DCEnt = new DCFIEntities())
{
Student studentInDB = (from s in DCEnt.Students
where s.StudentId == studentID
select s).FirstOrDefault();
if (studentInDB == null)
{
throw new Exception("No student with ID " + studentID);
}
DCEnt.Students.Remove(studentInDB);
studentInDB.Dismissed = true;
DCEnt.Students.Attach(studentInDB);
DCEnt.Entry(studentInDB).State = System.Data.Entity.EntityState.Modified;
int num = DCEnt.SaveChanges();
if (num != 1)
{
ret = false;
message = "Fail to Dismiss Student.";
}
}
return ret;
}
示例2: UpdateGradeLevel
public Boolean UpdateGradeLevel(ref GradeLevelBDO gBDO, ref string message)
{
message = "Grade Level updated successfully.";
Boolean ret = true;
using (var DCEnt = new DCFIEntities())
{
var gCode = gBDO.GradeLev;
GradeLevel gInDB = (from g in DCEnt.GradeLevels
where g.GradeLevel1 == gCode
select g).FirstOrDefault();
if (gInDB == null)
{
throw new Exception("No Grade Level " + gBDO.GradeLev);
}
DCEnt.GradeLevels.Remove(gInDB);
gInDB.GradeLevel1 = gBDO.GradeLev;
gInDB.Description = gBDO.Description;
DCEnt.GradeLevels.Attach(gInDB);
DCEnt.Entry(gInDB).State = System.Data.Entity.EntityState.Modified;
int num = DCEnt.SaveChanges();
if (num != 1)
{
ret = false;
message = "No grade level is updated.";
}
}
return ret;
}
示例3: AddLog
public Boolean AddLog(LogBDO log)
{
//string message = "Log Added Successfully";
bool ret = true;
try
{
Log l = new Log();
ConvertLogBDOToLog(log, l);
using (var DCEnt = new DCFIEntities())
{
DCEnt.Logs.Add(l);
DCEnt.Entry(l).State = System.Data.Entity.EntityState.Added;
int num = DCEnt.SaveChanges();
if (num < 1)
{
ret = false;
}
}
}
catch (DbEntityValidationException dbEx)
{
foreach (var validationErrors in dbEx.EntityValidationErrors)
{
foreach (var validationError in validationErrors.ValidationErrors)
{
Trace.TraceInformation("Property: {0} Error: {1}",
validationError.PropertyName,
validationError.ErrorMessage);
}
}
}
return ret;
}
示例4: CreateSY
public Boolean CreateSY(ref SchoolYearBDO syBDO, ref string message)
{
message = "School Year Added Successfully";
bool ret = true;
SchoolYear u = new SchoolYear()
{
SY = syBDO.SY,
CurrentSY = syBDO.CurrentSY
};
using (var DCEnt = new DCFIEntities())
{
DCEnt.SchoolYears.Attach(u);
DCEnt.Entry(u).State = System.Data.Entity.EntityState.Added;
int num = DCEnt.SaveChanges();
syBDO.SY = u.SY;
if (num != 1)
{
ret = false;
message = "Adding of School Year failed";
}
}
return ret;
}
示例5: CreateBuilding
public Boolean CreateBuilding(ref BuildingBDO buildBDO, ref string message)
{
message = "Building Added Successfully";
bool ret = true;
try {
Building b = new Building();
ConvertBuildingBDOToBuilding(buildBDO,b);
using (var DCEnt = new DCFIEntities())
{
DCEnt.Buildings.Add(b);
DCEnt.Entry(b).State = System.Data.Entity.EntityState.Added;
int num = DCEnt.SaveChanges();
buildBDO.BuildingCode = b.BuildingCode;
if (num < 1)
{
ret = false;
message = "Adding of Building failed";
}
}
}
catch (DbEntityValidationException dbEx)
{
foreach (var validationErrors in dbEx.EntityValidationErrors)
{
foreach (var validationError in validationErrors.ValidationErrors)
{
Trace.TraceInformation("Property: {0} Error: {1}",
validationError.PropertyName,
validationError.ErrorMessage);
}
}
}
return ret;
}
示例6: CreateTrait
public Boolean CreateTrait(ref TraitBDO tBDO, ref string message)
{
message = "Trait Added Successfully";
bool ret = true;
Trait t = new Trait();
try {
ConvertTraitBDOToTrait(tBDO, t);
using (var DCEnt = new DCFIEntities())
{
DCEnt.Traits.Attach(t);
DCEnt.Entry(t).State = System.Data.Entity.EntityState.Added;
int num = DCEnt.SaveChanges();
if (num != 1)
{
ret = false;
message = "Adding of Trait failed";
}
}
}
catch (DbEntityValidationException dbEx)
{
foreach (var validationErrors in dbEx.EntityValidationErrors)
{
foreach (var validationError in validationErrors.ValidationErrors)
{
Trace.TraceInformation("Property: {0} Error: {1}",
validationError.PropertyName,
validationError.ErrorMessage);
}
}
}
return ret;
}
示例7: ActivateUser
public Boolean ActivateUser(int userId, ref string message)
{
message = "User Activated successfully.";
Boolean ret = true;
using (var DCEnt = new DCFIEntities())
{
User userInDB = (from u in DCEnt.Users
where u.UserId == userId
select u).FirstOrDefault();
if (userInDB == null)
{
throw new Exception("No user with ID " + userId);
}
DCEnt.Users.Remove(userInDB);
userInDB.Deactivated = false;
DCEnt.Users.Attach(userInDB);
DCEnt.Entry(userInDB).State = System.Data.Entity.EntityState.Modified;
int num = DCEnt.SaveChanges();
if (num != 1)
{
ret = false;
message = "Activation Failed.";
}
}
return ret;
}
示例8: AddScholarshipDiscount
public Boolean AddScholarshipDiscount(ScholarshipDiscountBDO discount,int scholarshipCode, ref string message)
{
message = "Scholarship Discount Added Successfully";
Boolean ret = true;
ScholarshipDiscount sd = new ScholarshipDiscount();
try {
ConvertScholarshipDiscountBDOToScholarshipDiscount(discount, sd);
using (var DCEnt = new DCFIEntities())
{
DCEnt.ScholarshipDiscounts.Add(sd);
DCEnt.Entry(sd).State = System.Data.Entity.EntityState.Added;
int num = DCEnt.SaveChanges();
if (num != 1)
{
ret = false;
message = "Adding of Scholarship Discount failed";
}
}
}
catch (DbEntityValidationException dbEx)
{
foreach (var validationErrors in dbEx.EntityValidationErrors)
{
foreach (var validationError in validationErrors.ValidationErrors)
{
Trace.TraceInformation("Property: {0} Error: {1}",
validationError.PropertyName,
validationError.ErrorMessage);
}
}
}
return ret;
}
示例9: CreateFee
public Boolean CreateFee(ref FeeBDO fBDO, ref string message)
{
message = "Fee Added Successfully";
bool ret = true;
Fee f = new Fee();
try {
ConvertFeeBDOToFee(fBDO, f);
using (var DCEnt = new DCFIEntities())
{
DCEnt.Fees.Attach(f);
DCEnt.Entry(f).State = System.Data.Entity.EntityState.Added;
int num = DCEnt.SaveChanges();
if (num != 1)
{
ret = false;
message = "Adding of Fee failed";
}
}
}
catch (DbEntityValidationException dbEx)
{
foreach (var validationErrors in dbEx.EntityValidationErrors)
{
foreach (var validationError in validationErrors.ValidationErrors)
{
Trace.TraceInformation("Property: {0} Error: {1}",
validationError.PropertyName,
validationError.ErrorMessage);
}
}
}
return ret;
}
示例10: CreateCurriculum
public Boolean CreateCurriculum(ref CurriculumBDO cbdo, ref string message)
{
message = "Curriculum Added Successfully";
bool ret = true;
Curriculum cur = new Curriculum();
try {
ConvertCurriculumBDOToCurriculum(cbdo, cur);
using (var DCEnt = new DCFIEntities())
{
DCEnt.Curriculums.Add(cur);
DCEnt.Entry(cur).State = System.Data.Entity.EntityState.Added;
int num = DCEnt.SaveChanges();
if (num == 0)
{
ret = false;
message = "Adding of Curriculum failed";
}
}
}
catch (DbEntityValidationException dbEx)
{
foreach (var validationErrors in dbEx.EntityValidationErrors)
{
foreach (var validationError in validationErrors.ValidationErrors)
{
Trace.TraceInformation("Property: {0} Error: {1}",
validationError.PropertyName,
validationError.ErrorMessage);
}
}
}
return ret;
}
示例11: CreateGradeSection
public Boolean CreateGradeSection(ref GradeSectionBDO gsBDO, ref string message)
{
message = "Grade Section Added Successfully";
bool ret = true;
GradeSection gs = new GradeSection();
try{
ConvertGradeSectionBDOToGradeSection(gsBDO, gs);
using (var DCEnt = new DCFIEntities())
{
DCEnt.GradeSections.Attach(gs);
DCEnt.Entry(gs).State = System.Data.Entity.EntityState.Added;
int num = DCEnt.SaveChanges();
if (num != 1)
{
ret = false;
message = "Adding of Grade Section failed";
}
}
}
catch (DbEntityValidationException dbEx)
{
foreach (var validationErrors in dbEx.EntityValidationErrors)
{
foreach (var validationError in validationErrors.ValidationErrors)
{
Trace.TraceInformation("Property: {0} Error: {1}",
validationError.PropertyName,
validationError.ErrorMessage);
}
}
}
return ret;
}
示例12: CreateLearningArea
public Boolean CreateLearningArea(ref LearningAreaBDO laBDO, ref string message)
{
message = "Learning Area Added Successfully";
bool ret = true;
LearningArea la = new LearningArea();
try {
ConvertLearningAreaBDOToLearningArea(laBDO, la);
using (var DCEnt = new DCFIEntities())
{
DCEnt.LearningAreas.Add(la);
DCEnt.Entry(la).State = System.Data.Entity.EntityState.Added;
int num = DCEnt.SaveChanges();
if (num == 0)
{
ret = false;
message = "Adding of Learning Area failed";
}
}
}
catch (DbEntityValidationException dbEx)
{
foreach (var validationErrors in dbEx.EntityValidationErrors)
{
foreach (var validationError in validationErrors.ValidationErrors)
{
Trace.TraceInformation("Property: {0} Error: {1}",
validationError.PropertyName,
validationError.ErrorMessage);
}
}
}
return ret;
}
示例13: CreateUser
public Boolean CreateUser(ref UserBDO userBDO, ref string message)
{
message = "User Added Successfully";
bool ret = true;
UserType ut = new UserType()
{
UserType1 = userBDO.UserType.UsersType,
UserTypeCode = userBDO.UserType.UserTypeCode
};
User u = new User()
{
UserName = userBDO.UserName,
Password = userBDO.Password,
LastName = userBDO.LastName,
FirstName = userBDO.FirstName,
MiddleName = userBDO.MiddleName,
UserTypeCode = userBDO.UserType.UserTypeCode,
UserType = ut
};
using (var DCEnt = new DCFIEntities()) {
DCEnt.Users.Attach(u);
DCEnt.Entry(u).State = System.Data.Entity.EntityState.Added;
int num = DCEnt.SaveChanges();
userBDO.UserId = u.UserId;
if (num != 1) {
ret = false;
message = "Adding of User failed";
}
}
return ret;
}
示例14: DeleteSY
public Boolean DeleteSY(string schoolyear, ref string message)
{
message = "SY " + schoolyear + " Deleted successfully.";
Boolean ret = true;
using (var DCEnt = new DCFIEntities())
{
SchoolYear SYInDB = (from u in DCEnt.SchoolYears
where u.SY == schoolyear
select u).FirstOrDefault();
if (SYInDB == null)
{
throw new Exception("No SY " + schoolyear + " existed");
}
DCEnt.SchoolYears.Remove(SYInDB);
DCEnt.Entry(SYInDB).State = System.Data.Entity.EntityState.Deleted;
int num = DCEnt.SaveChanges();
if (num != 1)
{
ret = false;
message = "Deletion of SY Failed.";
}
}
return ret;
}
示例15: CreateUser
public Boolean CreateUser(ref UserBDO userBDO, ref string message)
{
message = "User Added Successfully";
bool ret = true;
UserType ut = new UserType()
{
UserType1 = userBDO.UserType.UsersType,
UserTypeCode = userBDO.UserType.UserTypeCode
};
User u = new User()
{
UserName = userBDO.UserName,
Password = userBDO.Password,
LastName = userBDO.LastName,
FirstName = userBDO.FirstName,
MiddleName = userBDO.MiddleName,
UserTypeCode = userBDO.UserType.UserTypeCode,
UserType = ut
};
try {
using (var DCEnt = new DCFIEntities()) {
DCEnt.Users.Attach(u);
DCEnt.Entry(u).State = System.Data.Entity.EntityState.Added;
int num = DCEnt.SaveChanges();
userBDO.UserId = u.UserId;
if (num != 1) {
ret = false;
message = "Adding of User failed";
}
}
}
catch (DbEntityValidationException dbEx)
{
foreach (var validationErrors in dbEx.EntityValidationErrors)
{
foreach (var validationError in validationErrors.ValidationErrors)
{
Trace.TraceInformation("Property: {0} Error: {1}",
validationError.PropertyName,
validationError.ErrorMessage);
}
}
}
return ret;
}