public static PersonInfoModel Find(string _personId) { var dc = new PersonInfoDataContext(SqlBuilder.ConnectionString); var records = from n in dc.PersonInfos where n.PersonId == _personId where n.IsDeleted == false select n; return(Build(records)); }
public void Save() { var now = DateTime.UtcNow; var dc = new PersonInfoDataContext(SqlBuilder.ConnectionString); if (this.Id == 0) { dc.PersonInfos.InsertOnSubmit(new PersonInfo { PersonGroupId = this.PersonGroupId, PersonId = this.PersonId, PersonName = this.PersonName, PersonNameYomi = this.PersonNameYomi, LastDetectedAt = now, IsDeleted = this.IsDeleted, CreatedAt = now, UpdatedAt = now }); } else { var records = from n in dc.PersonInfos where n.Id == this.Id select n; foreach (var r in records) { r.PersonName = this.PersonName; r.PersonNameYomi = this.PersonNameYomi; r.LastDetectedAt = (this.LastDetectedAt.HasValue ? this.LastDetectedAt.Value.LocalDateTime : r.LastDetectedAt); r.IsDeleted = this.IsDeleted; r.UpdatedAt = now; } } dc.SubmitChanges(); }