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


C# DbPropertyValues类代码示例

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


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

示例1: DetectUpdates

 /// <summary>
 /// Detects any updates on specified entity and tracks them via AlertManager.TrackablePropertyUpdated alert.
 /// </summary>
 /// <param name="entity">entity</param>
 /// <param name="originalValues">original properties values</param>
 /// <param name="currentValues">current properties values</param>
 /// <param name="properties">properties to track</param>
 /// <param name="updateCallback">action to call when update is detected. If it is null it defaults to AlertManager.TrackablePropertyChanged.</param>
 /// <remarks>
 /// This method would likely be called from <see cref="IModifyHook.OnModify">OnModify</see> implementation to track properties. 
 /// For tracking enum typed (state) properties see <see cref="DetectStateUpdates">DetectStateUpdates</see> method.
 /// </remarks>
 public static void DetectUpdates(this IBaseDO entity, 
     DbPropertyValues originalValues, DbPropertyValues currentValues, PropertyInfo[] properties,
     Action<string, object, PropertyInfo> updateCallback = null)
 {
     if (properties == null || properties.Length == 0)
         return;
     if (updateCallback == null)
     {
         updateCallback =
             (entityName, idValue, property) =>
             AlertManager.TrackablePropertyUpdated(entityName, property.Name, idValue, currentValues[property.Name]);
     }
     var type = entity.GetType();
     var idProperty = type.GetProperty("Id");
     var id = idProperty != null ? idProperty.GetValue(entity) : null;
     foreach (var property in properties)
     {
         if (!MiscUtils.AreEqual(originalValues[property.Name], currentValues[property.Name]))
         {
             string entityName;
             if (type.Name.EndsWith("DO", StringComparison.Ordinal))
                 entityName = type.Name.Remove(type.Name.Length - 2);
             else if (type.BaseType != null && type.BaseType.Name.EndsWith("DO", StringComparison.Ordinal))
                 entityName = type.BaseType.Name.Remove(type.BaseType.Name.Length - 2);
             else
                 entityName = type.Name;
             updateCallback(entityName, id, property);
         }
     }
 }
开发者ID:alexed1,项目名称:dtrack,代码行数:42,代码来源:EntityExtensions.cs

示例2: Non_Generic_DbPropertyValues_uses_ToObject_on_InternalPropertyValues

        public void Non_Generic_DbPropertyValues_uses_ToObject_on_InternalPropertyValues()
        {
            var properties = new Dictionary<string, object> { { "Id", 1 } };
            var values = new DbPropertyValues(new TestInternalPropertyValues<FakeTypeWithProps>(properties));

            var clone = (FakeTypeWithProps)values.ToObject();

            Assert.Equal(1, clone.Id);
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:9,代码来源:DbPropertyValuesTests.cs

示例3: OnModify

        public override void OnModify(DbPropertyValues originalValues, DbPropertyValues currentValues)
        {
            base.OnModify(originalValues, currentValues);

            var reflectionHelper = new ReflectionHelper<IncidentDO>();
            var priorityPropertyName = reflectionHelper.GetPropertyName(i => i.Priority);
            if (!MiscUtils.AreEqual(originalValues[priorityPropertyName], currentValues[priorityPropertyName])
                && IsHighPriority)
            {
                AlertManager.HighPriorityIncidentCreated(Id);
            }
        }
开发者ID:alexed1,项目名称:dtrack,代码行数:12,代码来源:IncidentDO.cs

示例4: PrintPropertyValues

 /// <summary>
 /// 记录帮助类
 /// </summary>
 private void PrintPropertyValues(DbPropertyValues values, IEnumerable<string> propertiesToPrint, int indent = 1)
 {
     foreach (var propertyName in propertiesToPrint)
     {
         var value = values[propertyName];
         if (value is DbPropertyValues)
         {
             Console.WriteLine("{0}- Complex Property: {1}", string.Empty.PadLeft(indent), propertyName);
             var complexPropertyValues = (DbPropertyValues)value;
             PrintPropertyValues(complexPropertyValues, complexPropertyValues.PropertyNames, indent + 1);
         }
         else
         {
             Console.WriteLine("{0}- {1}: {2}", string.Empty.PadLeft(indent), propertyName, values[propertyName]);
         }
     }
 }
开发者ID:TGHGH,项目名称:MesSolution,代码行数:20,代码来源:BreakAwayContext.cs

示例5: WritePropertyValues

 public static void WritePropertyValues(DbPropertyValues values, int indent = 1)
 {
     foreach (string propertyName in values.PropertyNames)
     {
         var value = values[propertyName];
         if (value is DbPropertyValues)
         {
             Console.WriteLine("{0} - Complex Property: {1}",
                               string.Empty.PadLeft(indent),
                               propertyName);
             WritePropertyValues((DbPropertyValues)value, indent + 1);
         }
         else
         {
             Console.WriteLine("{0} - {1}: {2}",
                 string.Empty.PadLeft(indent),
                 propertyName,values[propertyName]);
         }
     }
 }
开发者ID:JeremySBrown,项目名称:DbContextPresentation,代码行数:20,代码来源:TestHelpers.cs

示例6: DetectStateUpdates

 /// <summary>
 /// Detects any updates on specified entity state properties.
 /// </summary>
 /// <param name="entity">entity</param>
 /// <param name="originalValues">original properties values</param>
 /// <param name="currentValues">current properties values</param>
 public static void DetectStateUpdates(this IBaseDO entity,
     DbPropertyValues originalValues, DbPropertyValues currentValues)
 {
     var stateProperties = entity.GetStateProperties().ToArray();
     if (stateProperties.Length > 0)
     {
         entity.DetectUpdates(originalValues, currentValues, stateProperties,
                              (entityName, idValue, stateProperty) =>
                                  {
                                      var stateTemplateType =
                                          ReflectionHelper.ForeignKeyNavitationProperty(entity, stateProperty).
                                              PropertyType;
                                      var stateType =
                                          GetGenericInterface(stateTemplateType, typeof (IStateTemplate<>))
                                              .GetGenericArguments()[0];
                                      var stateName = stateType.Name;
                                      var stateKey = currentValues[stateProperty.Name];
                                      var stateValue = stateKey != null
                                                           ? stateType.GetFields().Single(f => Equals(f.GetValue(entity), stateKey)).Name
                                                           : null;
                                      AlertManager.EntityStateChanged(entityName, idValue, stateName, stateValue);
                                  });
     }
 }
开发者ID:alexed1,项目名称:dtrack,代码行数:30,代码来源:EntityExtensions.cs

示例7: Calling_SetValues_with_dictionary_of_derived_type_works

        public void Calling_SetValues_with_dictionary_of_derived_type_works()
        {
            var fromProperties = new Dictionary<string, object>
                                     {
                                         { "Id", 1 }
                                     };
            var fromValues = new DbPropertyValues(new TestInternalPropertyValues<FakeDerivedTypeWithProps>(fromProperties));

            var toProperties = new Dictionary<string, object>
                                   {
                                       { "Id", 0 }
                                   };
            var toValues = new DbPropertyValues(new TestInternalPropertyValues<FakeTypeWithProps>(toProperties));

            toValues.SetValues(fromValues);

            Assert.Equal(1, toValues["Id"]);
        }
开发者ID:junxy,项目名称:entityframework,代码行数:18,代码来源:DbPropertyValuesTests.cs

示例8: Non_Generic_DbPropertyValues_SetValues_with_a_dictionary_works_on_the_underlying_dictionary

        public void Non_Generic_DbPropertyValues_SetValues_with_a_dictionary_works_on_the_underlying_dictionary()
        {
            var fromValues = new DbPropertyValues(CreateSimpleValues());
            fromValues["Id"] = 1;

            var toValues = new DbPropertyValues(CreateSimpleValues());

            toValues.SetValues(fromValues);

            Assert.Equal(1, toValues["Id"]);
        }
开发者ID:junxy,项目名称:entityframework,代码行数:11,代码来源:DbPropertyValuesTests.cs

示例9: Attempt_to_copy_values_from_null_dictionary_on_non_generic_DbPropertyValues_throws

        public void Attempt_to_copy_values_from_null_dictionary_on_non_generic_DbPropertyValues_throws()
        {
            var values = new DbPropertyValues(new TestInternalPropertyValues<FakeTypeWithProps>());

            Assert.Equal("propertyValues", Assert.Throws<ArgumentNullException>(() => values.SetValues(null)).ParamName);
        }
开发者ID:junxy,项目名称:entityframework,代码行数:6,代码来源:DbPropertyValuesTests.cs

示例10: Calling_SetValues_with_instance_of_derived_type_works

        public void Calling_SetValues_with_instance_of_derived_type_works()
        {
            var properties = new Dictionary<string, object>
                                 {
                                     { "Id", 0 }
                                 };
            var values = new DbPropertyValues(new TestInternalPropertyValues<FakeTypeWithProps>(properties));

            values.SetValues(
                new FakeDerivedTypeWithProps
                    {
                        Id = 1
                    });

            Assert.Equal(1, values["Id"]);
        }
开发者ID:junxy,项目名称:entityframework,代码行数:16,代码来源:DbPropertyValuesTests.cs

示例11: PrintPropertyValues

 private static void PrintPropertyValues(DbPropertyValues values)
 {
     foreach (var propertyName in values.PropertyNames)
     {
         if (propertyName.ToString().Equals("userpwd"))
             Console.WriteLine(" - {0}: {1}", propertyName, values[propertyName]);
     }
 }
开发者ID:TGHGH,项目名称:MesSolution,代码行数:8,代码来源:Program.cs

示例12: GetLogContent

 //获取要记录的日志内容
 private string GetLogContent(DbPropertyValues values, IEnumerable<string> properties)
 {
     Dictionary<string, string> result = new Dictionary<string, string>();
     foreach (var propertyName in properties)
     {
         var value = values[propertyName];
         if (value is DbPropertyValues)
         {
             var complexPropertyValues = (DbPropertyValues)value;
             result.Add(propertyName, GetLogContent(complexPropertyValues, complexPropertyValues.PropertyNames));
         }
         else
         {
             result.Add(propertyName, (value ?? "").ToString());
         }
     }
     return result.ToJson();
 }
开发者ID:vinlon,项目名称:joyvio,代码行数:19,代码来源:WSICmsContextDB.cs

示例13: ResolverConflitos

 private static DbPropertyValues ResolverConflitos(DbPropertyValues dbPropertyValues1, DbPropertyValues dbPropertyValues2, DbPropertyValues dbValues)
 {
     throw new NotImplementedException();
 }
开发者ID:RASMiranda,项目名称:com.isel.si1314.asi,代码行数:4,代码来源:Program.cs

示例14: ClientChooses

 private void ClientChooses(DbPropertyValues current, DbPropertyValues other, DbPropertyValues resolved)
 {
     resolved["FirstName"] = other["FirstName"];
     resolved["LastName"] = current["LastName"];
 }
开发者ID:riezebosch,项目名称:adonetb,代码行数:5,代码来源:UnitTest1.cs

示例15: Complex_values_cannot_be_set_to_actual_complex_object_instance_in_a_property_dictionary

        public void Complex_values_cannot_be_set_to_actual_complex_object_instance_in_a_property_dictionary()
        {
            var values = new DbPropertyValues(CreateSimpleValues());

            Assert.Equal(
                Strings.DbPropertyValues_AttemptToSetNonValuesOnComplexProperty,
                Assert.Throws<ArgumentException>(() => values["NestedObject"] = new FakeTypeWithProps()).Message);
        }
开发者ID:junxy,项目名称:entityframework,代码行数:8,代码来源:DbPropertyValuesTests.cs


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