本文整理汇总了C#中EntityState类的典型用法代码示例。如果您正苦于以下问题:C# EntityState类的具体用法?C# EntityState怎么用?C# EntityState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EntityState类属于命名空间,在下文中一共展示了EntityState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValuePair
internal ValuePair(Func<object> originalValue, Func<object> newValue, string propertyName, EntityState state)
{
this.originalValue = checkDbNull(originalValue);
this.newValue = checkDbNull(newValue);
this.propertyName = propertyName;
this.state = state;
}
示例2: Cursor
public Cursor(EntityState es, Town t, XmlParser xp)
: base(es, "Cursor")
{
_town = t;
//Current data path is GameState->Town->Cursor
var path = es.Name + "->" + _town.Name + "->" + Name;
Body = new Body(this, "Body");
AddComponent(Body);
Physics = new Physics(this, "Physics");
AddComponent(Physics);
ImageRender = new ImageRender(this, "ImageRender");
AddComponent(ImageRender);
_aimleftkey = new DoubleInput(this, "AimLeftKey", Keys.A, Buttons.DPadLeft, PlayerIndex.One);
AddComponent(_aimleftkey);
_aimrightkey = new DoubleInput(this, "AimRightKeys", Keys.D, Buttons.DPadRight, PlayerIndex.One);
AddComponent(_aimrightkey);
_quickaimkey = new DoubleInput(this, "QuickAimKey", Keys.LeftShift, Buttons.RightShoulder, PlayerIndex.One);
AddComponent(_quickaimkey);
ParseXml(xp, path);
ImageRender.Origin = new Vector2(ImageRender.Texture.Width / 2f, ImageRender.Texture.Height / 2f);
Body.Position = _town.Body.Position +
(_town.TileRender.Origin - Vector2.UnitY * 40 - ImageRender.Origin) *
ImageRender.Scale;
}
示例3: StateChanged
public virtual void StateChanged([NotNull] StateEntry entry, EntityState oldState)
{
Check.NotNull(entry, "entry");
Check.IsDefined(oldState, "oldState");
Dispatch(l => l.StateChanged(entry, oldState));
}
示例4: StateChanging
public virtual void StateChanging([NotNull] StateEntry entry, EntityState newState)
{
Check.NotNull(entry, "entry");
Check.IsDefined(newState, "newState");
Dispatch(l => l.StateChanging(entry, newState));
}
示例5: GetAuditLogs
private static IEnumerable<AuditLog> GetAuditLogs(DbEntityEntry entityEntry, string userName, EntityState entityState, ObjectContext objectContext,
DateTime auditDateTime)
{
var returnValue = new List<AuditLog>();
var keyRepresentation = BuildKeyRepresentation(entityEntry, KeySeperator, objectContext);
var auditedPropertyNames = GetDeclaredPropertyNames(entityEntry.Entity.GetType(), objectContext.MetadataWorkspace);
foreach (var propertyName in auditedPropertyNames)
{
var currentValue = Convert.ToString(entityEntry.CurrentValues.GetValue<object>(propertyName));
var originalValue = Convert.ToString(entityEntry.GetDatabaseValues().GetValue<object>(propertyName));
if (entityState == EntityState.Modified)
if (originalValue == currentValue) //Values are the same, don't log
continue;
returnValue.Add(new AuditLog
{
KeyNames = keyRepresentation.Key,
KeyValues = keyRepresentation.Value,
OriginalValue = entityState != EntityState.Added
? originalValue
: null,
NewValue = entityState == EntityState.Modified || entityState == EntityState.Added
? currentValue
: null,
ColumnName = propertyName,
EventDateTime = auditDateTime,
EventType = entityState.ToString(),
UserName = userName,
TableName = entityEntry.Entity.GetType().Name
});
}
return returnValue;
}
示例6: EntityTool
public EntityTool()
{
Usage = ToolUsage.Both;
_location = new Coordinate(0, 0, 0);
_state = EntityState.None;
_sidebarPanel = new EntitySidebarPanel();
}
示例7: SetStateForSlot
public void SetStateForSlot(IDay day,
EntityState modified)
{
Day instance = ConvertToDay(day);
Entry(instance).State = EntityState.Modified;
}
示例8: NowRule
/// <summary>
/// Initializes a new instance of the <see cref="NowRule"/> class.
/// </summary>
/// <param name="property">The property.</param>
/// <param name="assignState">State of the object that can be assigned.</param>
/// <param name="timeZone">The time zone.</param>
public NowRule(string property, EntityState assignState, NowTimeZone timeZone)
: base(property, assignState)
{
// lower priority because we need to assign before validate
Priority = 10;
TimeZone = timeZone;
}
示例9: GetChangeTrackersEntries
private IEnumerable<object> GetChangeTrackersEntries(EntityState state)
{
return
from entry in this.databaseContext.ChangeTracker.Entries()
where entry.State == state
select entry.Entity;
}
示例10: HookEntityMetadata
/// <summary>
/// Initializes a new instance of the <see cref="HookEntityMetadata" /> class.
/// </summary>
/// <param name="hookType"></param>
/// <param name="entry"></param>
/// <param name="state">The state.</param>
/// <param name="context">The optional existing context (I believe this is usable for migrations).</param>
public HookEntityMetadata(HookType hookType, HookedEntityEntry entry, EntityState state, System.Data.Entity.DbContext context = null)
{
HookType = hookType;
Entry = entry;
_state = state;
CurrentContext = context;
}
示例11: ExtractedStateEntry
internal ExtractedStateEntry(EntityState state, PropagatorResult original, PropagatorResult current, IEntityStateEntry source)
{
State = state;
Original = original;
Current = current;
Source = source;
}
示例12: FlightVersionHistory
/// <summary>
/// Initializes a new instance of the <see cref="FlightVersionHistory"/> class.
/// </summary>
/// <param name="flight">
/// The flight.
/// </param>
/// <param name="entityState">
/// The entity state.
/// </param>
public FlightVersionHistory(Flight f, EntityState entityState)
{
this.State = entityState.ToString();
this.FlightId = f.FlightId;
this.Created = DateTime.Now;
this.Deleted = f.Deleted;
this.LastUpdated = f.LastUpdated;
this.LastUpdatedBy = f.LastUpdatedBy;
this.Description = f.Description;
this.Date = f.Date;
this.Departure = f.Departure;
this.Landing = f.Landing;
this.LandingCount = f.LandingCount;
this.PlaneId = f.PlaneId;
this.PilotId = f.PilotId;
this.PilotBackseatId = f.PilotBackseatId;
this.BetalerId = f.BetalerId;
this.StartTypeId = f.StartTypeId;
this.StartedFromId = f.StartedFromId;
this.LandedOnId = f.LandedOnId;
this.TachoDeparture = f.TachoDeparture;
this.TachoLanding = f.TachoLanding;
}
示例13: AttachGraph
/// <summary>
/// This API supports the Entity Framework Core infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future releases.
/// </summary>
public virtual void AttachGraph(InternalEntityEntry rootEntry, EntityState entityState)
=> _graphIterator.TraverseGraph(
new EntityEntryGraphNode(rootEntry, null)
{
NodeState = entityState
},
PaintAction);
示例14: GetAuditLogs
private static IEnumerable<AuditLog> GetAuditLogs(EntityEntry entityEntry, string userName, EntityState entityState)
{
var returnValue = new List<AuditLog>();
var keyRepresentation = BuildKeyRepresentation(entityEntry, KeySeperator);
var auditedPropertyNames =
entityEntry.Entity.GetType()
.GetProperties().Where(p => !p.GetCustomAttributes(typeof (DoNotAudit), true).Any())
.Select(info => info.Name);
foreach (var propertyEntry in entityEntry.Metadata.GetProperties()
.Where(x => auditedPropertyNames.Contains(x.Name))
.Select(property => entityEntry.Property(property.Name)))
{
if(entityState == EntityState.Modified)
if (Convert.ToString(propertyEntry.OriginalValue) == Convert.ToString(propertyEntry.CurrentValue)) //Values are the same, don't log
continue;
returnValue.Add(new AuditLog
{
KeyNames = keyRepresentation.Key,
KeyValues = keyRepresentation.Value,
OriginalValue = entityState != EntityState.Added
? Convert.ToString(propertyEntry.OriginalValue)
: null,
NewValue = entityState == EntityState.Modified || entityState == EntityState.Added
? Convert.ToString(propertyEntry.CurrentValue)
: null,
ColumnName = propertyEntry.Metadata.Name,
EventDateTime = DateTime.Now,
EventType = entityState.ToString(),
UserName = userName,
TableName = entityEntry.Entity.GetType().Name
});
}
return returnValue;
}
示例15: SetStateForSlot
public void SetStateForSlot(ISlot slot,
EntityState modified)
{
Slot instance = ConvertToSlot(slot);
Entry(instance).State = EntityState.Modified;
}