本文整理汇总了C#中Rock.Data.RockContext.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# RockContext.Dispose方法的具体用法?C# RockContext.Dispose怎么用?C# RockContext.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Data.RockContext
的用法示例。
在下文中一共展示了RockContext.Dispose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadIndividuals
//.........这里部分代码省略.........
{
newNote.IsAlert = true;
}
newNoteList.Add( newNote );
}
#endregion person create
var groupMember = new GroupMember();
groupMember.Person = person;
groupMember.GroupRoleId = groupRoleId;
groupMember.CreatedDateTime = ImportDateTime;
groupMember.ModifiedDateTime = ImportDateTime;
groupMember.CreatedByPersonAliasId = ImportPersonAliasId;
groupMember.GroupMemberStatus = GroupMemberStatus.Active;
if ( rowFamilyKey != currentFamilyGroup.ForeignKey )
{
// person not part of the previous family, see if that family exists or create a new one
currentFamilyGroup = ImportedFamilies.FirstOrDefault( g => g.ForeignKey == rowFamilyKey );
if ( currentFamilyGroup == null )
{
currentFamilyGroup = CreateFamilyGroup( row[FamilyName], rowFamilyKey );
newFamilyList.Add( currentFamilyGroup );
newFamilies++;
}
else
{
lookupContext.Groups.Attach( currentFamilyGroup );
lookupContext.Entry( currentFamilyGroup ).State = EntityState.Modified;
}
currentFamilyGroup.Members.Add( groupMember );
}
else
{
// person is part of this family group, check if they're a visitor
if ( isFamilyRelationship || currentFamilyGroup.Members.Count() < 1 )
{
currentFamilyGroup.Members.Add( groupMember );
}
else
{
var visitorFamily = CreateFamilyGroup( person.LastName + " Family", rowFamilyKey );
visitorFamily.Members.Add( groupMember );
newFamilyList.Add( visitorFamily );
newVisitorList.Add( visitorFamily );
newFamilies++;
}
}
// look ahead 1 row
string rowNextFamilyKey = "-1";
if ( (row = csvData.Database.FirstOrDefault()) != null )
{
rowNextFamilyKey = row[FamilyId];
}
newPeople++;
completed++;
if ( completed % (ReportingNumber * 10) < 1 )
{
ReportProgress( 0, string.Format( "{0:N0} people imported.", completed ) );
}
if ( newPeople >= ReportingNumber && rowNextFamilyKey != currentFamilyGroup.ForeignKey )
{
SaveIndividuals( newFamilyList, newVisitorList, newNoteList );
lookupContext.SaveChanges();
ReportPartialProgress();
// Clear out variables
currentFamilyGroup = new Group();
newFamilyList.Clear();
newVisitorList.Clear();
newNoteList.Clear();
newPeople = 0;
}
}
else
{
row = csvData.Database.FirstOrDefault();
}
}
// Save any changes to new families
if ( newFamilyList.Any() )
{
SaveIndividuals( newFamilyList, newVisitorList, newNoteList );
}
// Save any changes to existing families
lookupContext.SaveChanges();
DetachAllInContext( lookupContext );
lookupContext.Dispose();
ReportProgress( 0, string.Format( "Finished individual import: {0:N0} families and {1:N0} people added.", newFamilies, completed ) );
return completed;
}