当前位置: 首页>>代码示例>>C#>>正文


C# Objects.ObjectStateEntry类代码示例

本文整理汇总了C#中System.Data.Objects.ObjectStateEntry的典型用法代码示例。如果您正苦于以下问题:C# ObjectStateEntry类的具体用法?C# ObjectStateEntry怎么用?C# ObjectStateEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ObjectStateEntry类属于System.Data.Objects命名空间,在下文中一共展示了ObjectStateEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsTargetEntity

        public virtual bool IsTargetEntity(ObjectStateEntry item)
        {

            return item.State != EntityState.Detached &&
                   TargetType.IsInstanceOfType(item.Entity);

        }
开发者ID:Eugene-Murray,项目名称:Contract_Validus,代码行数:7,代码来源:TypeInterceptor.cs

示例2: GetIdentifierValue

 /// <summary>
 /// Gets the identifier value for the entity in the ObjectStateEntry.
 /// </summary>
 /// <param name="objectStateEntry">The ObjectStateEntry.</param>
 /// <returns>The identifier value.</returns>
 /// <remarks>
 /// When auditing Adds, this needs to be called AFTER SaveChanges, or else it will return null.
 /// </remarks>
 public static string GetIdentifierValue(ObjectStateEntry objectStateEntry)
 {
     if (objectStateEntry == null)
     {
         throw new ArgumentNullException("objectStateEntry");
     }
     string id = null;
     var entityKey = objectStateEntry.EntityKey;
     if (entityKey != null)
     {
         var keyValues = entityKey.EntityKeyValues;
         if (keyValues != null)
         {
             if (keyValues.Length == 1)
             {
                 id = keyValues[0].Value.ToString();
             }
             else if (keyValues.Length > 1)
             {
                 id = string.Join(_composikeKeySeparator, keyValues.OrderBy(k => k.Key).Select(k => k.Value.ToString()).ToArray());
             }
         }
     }
     return id;
 }
开发者ID:rickeygalloway,项目名称:Test,代码行数:33,代码来源:IdentifierUtility.cs

示例3: TrackOriginalValue

 /// <summary>
 /// Tracks the original value.
 /// </summary>
 /// <param name="objectStateEntry">The object state entry.</param>
 private void TrackOriginalValue(ObjectStateEntry objectStateEntry)
 {
     object propertyValue = objectStateEntry.OriginalValues[PropertyName];
     if (propertyValue != null)
     {
         OriginalValue = propertyValue.ToString();
     }
 }
开发者ID:rickeygalloway,项目名称:Test,代码行数:12,代码来源:TrackingAuditEntityProperty.cs

示例4: TrackNewValue

 /// <summary>
 /// Tracks the new value.
 /// </summary>
 /// <param name="objectStateEntry">The object state entry.</param>
 private void TrackNewValue(ObjectStateEntry objectStateEntry)
 {
     object propertyValue = objectStateEntry.CurrentValues[PropertyName];
     if (propertyValue != null)
     {
         NewValue = propertyValue.ToString();
     }
 }
开发者ID:rickeygalloway,项目名称:Test,代码行数:12,代码来源:TrackingAuditEntityProperty.cs

示例5: GetUpdatedEntityValues

 private static IEnumerable<Tuple<string, object, object>> GetUpdatedEntityValues(ObjectStateEntry entry)
 {
     foreach (string propname in entry.GetModifiedProperties())
     {
         object newval = entry.CurrentValues[propname];
         object oldval = entry.OriginalValues[propname];
         yield return Tuple.Create(propname, newval, oldval);
     }
 }
开发者ID:koder05,项目名称:fogel-ba,代码行数:9,代码来源:EFExtension.cs

示例6: TrackDelete

 /// <summary>
 /// Tracks the delete.
 /// </summary>
 /// <param name="objectStateEntry">The object state entry.</param>
 public void TrackDelete(ObjectStateEntry objectStateEntry)
 {
     if (objectStateEntry == null)
     {
         throw new ArgumentNullException("objectStateEntry");
     }
     AuditEntities.Add(new EntityDeletedAudit(objectStateEntry));
     RemoveReads();
 }
开发者ID:rickeygalloway,项目名称:Test,代码行数:13,代码来源:TrackingAuditEvent.cs

示例7: TrackingAuditEntity

 public TrackingAuditEntity(ObjectStateEntry objectStateEntry, AuditEntityAction action)
 {
     if (objectStateEntry == null)
     {
         throw new ArgumentNullException("objectStateEntry");
     }
     EntityType = EntityTypeResolver.ResolveActualEntityType(objectStateEntry.Entity).Name;
     EntityIdentifier = IdentifierUtility.GetIdentifierValue(objectStateEntry);
     AuditEntityAction = action;
     AuditEntityProperties = new Collection<AuditEntityProperty>();
 }
开发者ID:rickeygalloway,项目名称:Test,代码行数:11,代码来源:TrackingAuditEntity.cs

示例8: GetAddedEntityValues

 private static IEnumerable<Tuple<string, object, object>> GetAddedEntityValues(ObjectStateEntry entry)
 {
     foreach (var propinfo in entry.CurrentValues.DataRecordInfo.FieldMetadata)
     {
         object newval = entry.CurrentValues[propinfo.FieldType.Name];
         if (newval.GetType() == typeof(EntityKey))
         {
             newval = ((EntityKey)newval).EntityKeyValues.Select(k => k.Value).FirstOrDefault();    
         }
         yield return Tuple.Create(propinfo.FieldType.Name, newval, (object)null);
     }
 }
开发者ID:koder05,项目名称:fogel-ba,代码行数:12,代码来源:EFExtension.cs

示例9: TrackProperties

 /// <summary>
 /// Tracks the properties.
 /// </summary>
 /// <param name="objectStateEntry">The object state entry.</param>
 protected void TrackProperties(ObjectStateEntry objectStateEntry)
 {
     var currentValues = objectStateEntry.CurrentValues;
     for (int ordinal = 0; ordinal < currentValues.FieldCount; ordinal++)
     {
         var propertyName = currentValues.GetName(ordinal);
         if (!IsStoreGenerated(propertyName, objectStateEntry))
         {
             AuditEntityProperties.Add(new TrackingAuditEntityProperty(propertyName, objectStateEntry));
         }
     }
 }
开发者ID:rickeygalloway,项目名称:Test,代码行数:16,代码来源:EntityAddedAudit.cs

示例10: GetAction

 private static AuditAction GetAction(ObjectStateEntry entity)
 {
     switch (entity.State)
     {
         case EntityState.Added:
             return AuditAction.Added;
         case EntityState.Deleted:
             return AuditAction.Deleted;
         default:
             return AuditAction.Modified;
     }
 }
开发者ID:dioptre,项目名称:nkd,代码行数:12,代码来源:AuditEntryState.cs

示例11: TrackProperties

 /// <summary>
 /// Tracks the properties.
 /// </summary>
 /// <param name="objectStateEntry">The object state entry.</param>
 protected void TrackProperties(ObjectStateEntry objectStateEntry)
 {
     foreach (string propertyName in objectStateEntry.GetModifiedProperties())
     {
         if (!IsStoreGenerated(propertyName, objectStateEntry))
         {
             var auditProperty = new TrackingAuditEntityProperty(propertyName, objectStateEntry);
             if (auditProperty.HasChanges)
             {
                 AuditEntityProperties.Add(auditProperty);
             }
         }
     }
 }
开发者ID:rickeygalloway,项目名称:Test,代码行数:18,代码来源:EntityUpdatedAudit.cs

示例12: ObjectStateEntryDbDataRecord

 internal ObjectStateEntryDbDataRecord(RelationshipEntry cacheEntry)
 {
     EntityUtil.CheckArgumentNull(cacheEntry, "cacheEntry");
     Debug.Assert(!cacheEntry.IsKeyEntry, "Cannot create an ObjectStateEntryDbDataRecord for a key entry");
     switch (cacheEntry.State)
     {
         case EntityState.Unchanged:
         case EntityState.Modified:
         case EntityState.Deleted:
             _cacheEntry = cacheEntry;
             break;
         default:
             Debug.Assert(false, "A DbDataRecord cannot be created for an entity object that is in an added or detached state.");
             break;
     }
 }
开发者ID:uQr,项目名称:referencesource,代码行数:16,代码来源:ObjectStateEntryDbDataRecord.cs

示例13: TrackingAuditEntityProperty

 /// <summary>
 /// Initializes a new instance of the <see cref="TrackingAuditEntityProperty"/> class.
 /// </summary>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="objectStateEntry">The object state entry.</param>
 public TrackingAuditEntityProperty(string propertyName, ObjectStateEntry objectStateEntry)
 {
     if (objectStateEntry == null)
     {
         throw new ArgumentNullException("objectStateEntry");
     }
     if (string.IsNullOrEmpty(propertyName))
     {
         throw new ArgumentNullException("propertyName");
     }
     PropertyName = propertyName;
     TrackNewValue(objectStateEntry);
     if (objectStateEntry.State == EntityState.Modified)
     {
         TrackOriginalValue(objectStateEntry);
     }
 }
开发者ID:rickeygalloway,项目名称:Test,代码行数:22,代码来源:TrackingAuditEntityProperty.cs

示例14: ValidateBelongsTo

		static void ValidateBelongsTo(this AssociationEndMember end, ObjectStateEntry entry)
		{
			if (!entry.IsRelationship)
			{
				throw new ArgumentException("is not a relationship entry", "entry");
			}

			var fieldMetadata =
					entry.UsableValues().DataRecordInfo.FieldMetadata;
			if (fieldMetadata[0].FieldType as AssociationEndMember != end &&
				fieldMetadata[1].FieldType as AssociationEndMember != end)
			{
				throw new InvalidOperationException(string.Format(
						"association end {0} does not participate in the " +
						"relationship {1}", end, entry));
			}
		}
开发者ID:ptrefren,项目名称:EntityFramework.Extended,代码行数:17,代码来源:Extensions.cs

示例15: ObjectStateEntryDbDataRecord

 internal ObjectStateEntryDbDataRecord(EntityEntry cacheEntry, StateManagerTypeMetadata metadata, object userObject)
 {
     //Contract.Requires(cacheEntry != null);
     //Contract.Requires(userObject != null);
     //Contract.Requires(metadata != null);
     Debug.Assert(!cacheEntry.IsKeyEntry, "Cannot create an ObjectStateEntryDbDataRecord for a key entry");
     switch (cacheEntry.State)
     {
         case EntityState.Unchanged:
         case EntityState.Modified:
         case EntityState.Deleted:
             _cacheEntry = cacheEntry;
             _userObject = userObject;
             _metadata = metadata;
             break;
         default:
             Debug.Assert(false, "A DbDataRecord cannot be created for an entity object that is in an added or detached state.");
             break;
     }
 }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:20,代码来源:ObjectStateEntryDbDataRecord.cs


注:本文中的System.Data.Objects.ObjectStateEntry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。