本文整理汇总了C#中CmsEntities类的典型用法代码示例。如果您正苦于以下问题:C# CmsEntities类的具体用法?C# CmsEntities怎么用?C# CmsEntities使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CmsEntities类属于命名空间,在下文中一共展示了CmsEntities类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Fix
public void Fix()
{
CmsEntities cee = new CmsEntities();
List<IssueRelatedIssue> itemsToAdd = new List<IssueRelatedIssue>();
var allRelatedIssues = cee.IssueRelatedIssues.ToList();
foreach (var relatedIssue in allRelatedIssues)
{
var reverseExist = (allRelatedIssues.FirstOrDefault(x => x.RelatedIssueId == relatedIssue.IssueId));
if (reverseExist == null)
{
if (itemsToAdd.FirstOrDefault(x => x.IssueId == relatedIssue.IssueId && x.RelatedIssueId == relatedIssue.RelatedIssueId) == null)
{
itemsToAdd.Add(new IssueRelatedIssue {IssueId = relatedIssue.RelatedIssueId, RelatedIssueId = relatedIssue.IssueId});
}
}
}
if (itemsToAdd.Any())
{
foreach (var issueRelatedIssue in itemsToAdd)
{
cee.IssueRelatedIssues.Add(new IssueRelatedIssue { IssueId = issueRelatedIssue.IssueId, RelatedIssueId = issueRelatedIssue.RelatedIssueId });
}
}
cee.SaveChanges();
}
示例2: DeleteIssueApprovalDuplicates
public void DeleteIssueApprovalDuplicates()
{
using (CmsEntities cee = new CmsEntities(120,mConnectCMS))
{
var issues = (from x in cee.Issues orderby x.Id select x).ToList();
foreach (var issue in issues)
{
Console.Out.WriteLine("Processing issue {0}", issue.Id);
var issueApprovals = (from x in cee.IssueApprovals
where x.IssueId == issue.Id
select x);
var duplicates = issueApprovals.GroupBy(x => new { x.IssueId, x.IssueCategoryId })
.Where(g => g.Count() > 1)
.Select(g => g.Key)
.ToList();
foreach (var issueApproval in duplicates)
{
var delete = (from x in cee.IssueApprovals
where x.IssueId == issueApproval.IssueId
&& x.IssueCategoryId == issueApproval.IssueCategoryId
select x).OrderByDescending(x => x.Date).Skip(1).ToList();
delete.ForEach(x => cee.IssueApprovals.Remove(x));
}
}
cee.SaveChanges();
}
}
示例3: TuningPropertiesImporter
public TuningPropertiesImporter(ImportFileMetaData metadata)
{
MetaData = metadata;
WorkSheetName = ImportWorkSheetName.TuningProperties.ToString();
Cee = new CmsEntities(5000);
Cee.Configuration.LazyLoadingEnabled = false;
}
示例4: IssueSystemReferencesImporter
public IssueSystemReferencesImporter(ImportFileMetaData metadata)
{
MetaData = metadata;
WorkSheetName = ImportWorkSheetName.SystemReferences.ToString();
Cee = new CmsEntities(5000);
Cee.Configuration.LazyLoadingEnabled = false;
}
示例5: Export
public string Export(int[] pipeIdList, string usersBaseReportingDirectory)
{
if (pipeIdList == null) throw new ArgumentNullException("pipeIdList");
if (String.IsNullOrEmpty(usersBaseReportingDirectory)) throw new ArgumentNullException("usersBaseReportingDirectory");
if (!Directory.Exists(usersBaseReportingDirectory))
{
Directory.CreateDirectory(usersBaseReportingDirectory);
}
using (CmsEntities cee = new CmsEntities())
{
IList<PipeComponent> allPipeComponents = (from x in cee.PipeComponents
.Include("Pipe")
.Include("PipeComponentType")
.Include("PipePropertyValues")
.Include("Pipe.PipeClass")
.Include("Pipe.PipeSize")
.Include("Pipe.PipeFluidCode")
.Include("Pipe.PipeSpecialFeature")
.Include("Pipe.Area")
where pipeIdList.Contains(x.Id)
select x).ToList();
return RunExport(cee, usersBaseReportingDirectory, allPipeComponents);
}
}
示例6: InterlockRiskImporter
public InterlockRiskImporter(ImportFileMetaData metadata)
{
MetaData = metadata;
WorkSheetName = ImportWorkSheetName.InterlockRisks.ToString();
Cee = new CmsEntities(5000);
Cee.Configuration.LazyLoadingEnabled = false;
}
示例7: ElectricalImporter
public ElectricalImporter(ImportFileMetaData metadata)
{
MetaData = metadata;
WorkSheetName = ImportWorkSheetName.ElectricalEquipments.ToString();
Cee = new CmsEntities(5000);
Cee.Configuration.LazyLoadingEnabled = false;
}
示例8: Cji5Importer
//private readonly CmsEntities mCee;
public Cji5Importer(ImportFileMetaData metadata)
{
MetaData = metadata;
WorkSheetName = ImportWorkSheetName.Financial.ToString();
Cee = new CmsEntities(5000);
Cee.Configuration.LazyLoadingEnabled = false;
}
示例9: AddIssueTypeSubType
public DbOperationResult<IssueTypeSubType> AddIssueTypeSubType(IssueType issueType, IssueSubType issueSubType)
{
var result = new DbOperationResult<IssueTypeSubType>();
//guard against duplicate.
using (var cee = new CmsEntities())
{
int k = (from x in cee.IssueTypeSubTypes where x.IssueTypeId == issueType.Id && x.IssueSubTypeId == issueSubType.Id select x.Id).Count();
if (k > 0)
{
result.ServerErrorMessages.Add(string.Format("Insert Failed. An IssueTypeSubType with the combination IssueType Name: '{0}' and Issue SubType Name: '{1}' already exists.", issueType.Name, issueSubType.Name));
return result;
}
var typeSubType = new IssueTypeSubType
{
IssueSubTypeId = issueSubType.Id,
IssueTypeId = issueType.Id,
Ordinal = 0
};
cee.IssueTypeSubTypes.Add(typeSubType);
cee.SaveChanges();
result.EntityResult = typeSubType;
}
return result;
}
示例10: AddElectricalComponentTypeProperty
public ElectricalEquipmentComponentTypeProperty AddElectricalComponentTypeProperty(ElectricalEquipmentComponentTypeProperty mecp)
{
using (CmsEntities cee = new CmsEntities())
{
//Check if this component property already exist
ElectricalEquipmentComponentTypeProperty temp = (from x in cee.ElectricalEquipmentComponentTypeProperties
where x.ElectricalEquipmentPropertyId == mecp.ElectricalEquipmentPropertyId &&
x.ElectricalEquipmentComponentTypeId == mecp.ElectricalEquipmentComponentTypeId
select x).FirstOrDefault();
if (temp == null)
{
//Add new Component Type
temp = new ElectricalEquipmentComponentTypeProperty();
temp.ElectricalEquipmentPropertyId = mecp.ElectricalEquipmentPropertyId;
temp.ElectricalEquipmentComponentTypeId = mecp.ElectricalEquipmentComponentTypeId;
temp.Ordinal = mecp.Ordinal;
cee.ElectricalEquipmentComponentTypeProperties.Add(temp);
cee.SaveChanges();
}
else
{
temp.Ordinal = mecp.Ordinal;
cee.SaveChanges();
}
return temp;
}
}
示例11: DeleteRole
public DbOperationResult DeleteRole(int roleId)
{
using (CmsEntities cee = new CmsEntities())
{
Role role = (from x in cee.Roles where x.Id == roleId select x).FirstOrDefault();
if (role == null)
{
DbOperationResult result = new DbOperationResult();
result.ServerErrorMessages.Add(string.Format("Cannot find the Role to delete with Id = {0}", role.Id));
return result;
}
cee.Roles.Remove(role);
try
{
cee.SaveChanges();
}
catch (Exception ex)
{
log.Error("", ex, ex.ToString());
DbOperationResult result = new DbOperationResult();
result.ServerErrorMessages.Add(ex.Message);
return result;
}
}
return new DbOperationResult();
}
示例12: MobilePlantComponentImporter
public MobilePlantComponentImporter(ImportFileMetaData metadata)
{
MetaData = metadata;
WorkSheetName = ImportWorkSheetName.Components.ToString();
Cee = new CmsEntities(5000);
Cee.Configuration.LazyLoadingEnabled = false;
}
示例13: SaveIssueFiles
public DbOperationResult SaveIssueFiles(List<IssueFile> issueFiles)
{
try
{
using (var cee = new CmsEntities())
{
foreach (IssueFile attachment in issueFiles)
{
IssueFile existingAttachment = (from x in cee.IssueFiles
where x.Filename == attachment.Filename &&
x.Path == attachment.Path
select x).FirstOrDefault();
if (existingAttachment != null)
{
existingAttachment.Description = attachment.Description;
}
else
{
attachment.User = null;
attachment.Issue = null;
attachment.AttachmentType = null;
cee.IssueFiles.Add(attachment);
}
}
cee.SaveChanges();
}
}
catch (Exception ex)
{
return new DbOperationResult { ServerErrorMessages = new List<string> { ex.Message } };
}
return new DbOperationResult();
}
示例14: Migrate
public void Migrate()
{
using (CmsEntities cee = new CmsEntities(120,mConnectCMS))
{
//var issues = (from x in cee.Issues orderby x.Id
// where
// x.TimeToImplement.HasValue
// || x.TimeToTest.HasValue
// || x.TimeToDocument.HasValue
// || x.ActualTimeImplement.HasValue
// || x.ActualTimeTest.HasValue
// || x.ActualTimeDocument.HasValue
// || x.Budgeted.HasValue
// || x.FundingType != null
// || x.EstimateScope.HasValue
// || x.ActualScope.HasValue
// || x.EstimateDesign.HasValue
// || x.ActualDesign.HasValue
// || x.HasScope.HasValue
// || x.HasDesign.HasValue
// || x.HasScopeUserId.HasValue
// || x.HasDesignUserId.HasValue
// || x.EstimatedCost.HasValue
// || x.Effort.HasValue
// || x.Reward.HasValue
// select x).ToList();
//foreach (var issue in issues)
//{
// Console.Out.WriteLine("Processing issue {0}", issue.Id);
// if (issue.IssueTracking == null)
// {
// issue.IssueTracking = new IssueTracking();
// }
// issue.IssueTracking.ImplementedEstimate = issue.TimeToImplement;
// issue.IssueTracking.TestedEstimate = issue.TimeToTest;
// issue.IssueTracking.DocumentedEstimate = issue.TimeToDocument;
// issue.IssueTracking.ImplementedActual = issue.ActualTimeImplement;
// issue.IssueTracking.TestedActual = issue.ActualTimeTest;
// issue.IssueTracking.DocumentedActual = issue.ActualTimeDocument;
// issue.IssueTracking.Budgeted = issue.Budgeted;
// issue.IssueTracking.FundingType = issue.FundingType;
// issue.IssueTracking.ScopedEstimate = issue.EstimateScope;
// issue.IssueTracking.ScopedActual = issue.ActualScope;
// issue.IssueTracking.PeerReviewEstimate = issue.EstimateDesign;
// issue.IssueTracking.PeerReviewActual = issue.ActualDesign;
// issue.IssueTracking.Scoped = issue.HasScope.HasValue && issue.HasScope.Value;
// issue.IssueTracking.PeerReviewed = issue.HasDesign.HasValue && issue.HasDesign.Value;
// issue.IssueTracking.ScopedUserId = issue.HasScopeUserId;
// issue.IssueTracking.PeerReviewedUserId = issue.HasDesignUserId;
// issue.IssueTracking.EstimatedCost = issue.EstimatedCost;
// issue.IssueTracking.Effort = issue.Effort;
// issue.IssueTracking.Return = issue.Reward;
//}
//cee.SaveChanges();
}
}
示例15: GetAppSettingValue
public static string GetAppSettingValue(CommonUtils.AppSettingKey keyIn)
{
using (CmsEntities cee = new CmsEntities())
{
string keyInText = keyIn.ToString();
return (from x in cee.AppSettings where string.Compare(keyInText, x.Key, StringComparison.OrdinalIgnoreCase) == 0 select x.Value).FirstOrDefault();
}
}