コード例 #1
0
        public UserProfile Save(UserProfile entity)
        {
            using (Dbml.DataClassesDataContext db = new Dbml.DataClassesDataContext(this.ConnectionString))
            {
                Dbml.UserProfile dbItem = db.UserProfiles.Where(x => x.Id == entity.Id).SingleOrDefault();
                bool isNew = false;
                if (dbItem == null)
                {
                    dbItem = new Dbml.UserProfile();
                    isNew = true;
                }
                else
                {
                    //remove them for refresh
                    //wish there was a better way to do this but...
                    db.Application_UserProfiles.DeleteAllOnSubmit
                    (
                        db.Application_UserProfiles.Where(x => x.UserProfileId ==  entity.Id)
                    );
                }
                foreach( Ent.Application a in entity.Applications)
                {
                    Dbml.Application_UserProfile dbAppUser = new Dbml.Application_UserProfile();
                    dbAppUser.UserProfileId = entity.Id;
                    dbAppUser.ApplicationId = a.Id;
                    dbItem.Application_UserProfiles.Add(dbAppUser);
                }
                dbItem.Name = entity.Name;
                dbItem.Email = entity.Email;
                dbItem.LastSignInDate = entity.LastSignInDate;
                dbItem.OpenIdId = entity.OpenIdId;
                dbItem.RegisterDate = entity.RegisterDate;
                dbItem.UserName = entity.UserName;
                dbItem.ModifiedBy = entity.ModifiedBy;
                dbItem.ModifiedDate = entity.ModifiedDate;
                dbItem.CreatedDate = entity.CreatedDate;
                dbItem.CreatedBy = entity.CreatedBy;

                if (isNew)
                {
                    db.UserProfiles.InsertOnSubmit(dbItem);
                }
                db.SubmitChanges();

                entity.Id = dbItem.Id;
                return entity;
            }
        }
コード例 #2
0
		private void detach_Application_UserProfiles(Application_UserProfile entity)
		{
			this.SendPropertyChanging();
			entity.UserProfile = null;
		}
コード例 #3
0
 partial void DeleteApplication_UserProfile(Application_UserProfile instance);
コード例 #4
0
 partial void UpdateApplication_UserProfile(Application_UserProfile instance);
コード例 #5
0
 partial void InsertApplication_UserProfile(Application_UserProfile instance);
コード例 #6
0
		private void attach_Application_UserProfiles(Application_UserProfile entity)
		{
			this.SendPropertyChanging();
			entity.Application = this;
		}