本文整理汇总了C#中DbEntityEntry.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# DbEntityEntry.ToString方法的具体用法?C# DbEntityEntry.ToString怎么用?C# DbEntityEntry.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbEntityEntry
的用法示例。
在下文中一共展示了DbEntityEntry.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetEntityKeyUpdated
/// <summary>
/// Gets the entity key updated.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="entry">The entry.</param>
/// <param name="state">The state.</param>
/// <param name="entitySetName">Name of the entity set.</param>
/// <returns>returns key</returns>
private string GetEntityKeyUpdated(ObjectContext context, DbEntityEntry entry, EntityState state, out string entitySetName)
{
var keyBuilder = new StringBuilder();
ObjectStateEntry newEntry = null;
if (!context.ObjectStateManager.TryGetObjectStateEntry(entry.Entity, out newEntry))
{
entitySetName = String.Empty;
Trace.TraceInformation("Can't find state entry for \"{0}\"", entry.ToString());
return null;
}
entitySetName = newEntry.EntitySet.Name;
var keys = state == EntityState.Added ? context.CreateEntityKey(newEntry.EntitySet.Name, entry.Entity) : newEntry.EntityKey;
foreach (var key in keys.EntityKeyValues)
{
if (keyBuilder.Length > 0)
{
keyBuilder.Append(",");
}
keyBuilder.Append(Convert.ToString(key.Value));
}
return keyBuilder.ToString();
}