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


C# Delta.GetChangedPropertyNames方法代码示例

本文整理汇总了C#中System.Web.OData.Delta.GetChangedPropertyNames方法的典型用法代码示例。如果您正苦于以下问题:C# Delta.GetChangedPropertyNames方法的具体用法?C# Delta.GetChangedPropertyNames怎么用?C# Delta.GetChangedPropertyNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.OData.Delta的用法示例。


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

示例1: Patch

        public IHttpActionResult Patch([FromODataUri] int key, Delta<Product> patch)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            Delta<V2VM.Product> v2Patch = new Delta<V2VM.Product>();
            foreach (string name in patch.GetChangedPropertyNames())
            {
                object value;
                if (patch.TryGetPropertyValue(name, out value))
                {
                    v2Patch.TrySetPropertyValue(name, value);
                }
            }
            var v2Product = _repository.Patch((long)key, v2Patch, Request);
            return Updated(Mapper.Map<Product>(v2Product));
        }
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:19,代码来源:ProductsV1Controller.cs

示例2: Patch

        public IHttpActionResult Patch(int key, Delta<SpatialCustomer> customer)
        {
            // Assert part
            Assert.Equal(3, key);

            Assert.Equal(new[] {"Location"}, customer.GetChangedPropertyNames());

            object value;
            customer.TryGetPropertyValue("Location", out value);

            GeographyPoint point = value as GeographyPoint;
            Assert.NotNull(point);
            Assert.Equal(7, point.Longitude);
            Assert.Equal(8, point.Latitude);
            Assert.Equal(9, point.Z);
            Assert.Equal(10, point.M);

            return Ok();
        }
开发者ID:chinadragon0515,项目名称:WebApi,代码行数:19,代码来源:SpatialController.cs

示例3: Patch

		public async Task<IHttpActionResult> Patch([FromODataUri] string key, Delta<Namespace> ns, [ValueProvider(typeof(CultureValueProviderFactory))] string culture = "en-US")
		{
			if (!ModelState.IsValid)
			{
				return BadRequest(ModelState);
			}
			var entity = await db.Dictionaries.FindAsync(key);
			if (entity == null)
			{
				return NotFound();
			}

			foreach (var property in ns.GetChangedPropertyNames())
			{
				if (property == nameof(entity.Description))
				{
					entity.Description = ns.GetEntity().Description;
				}
			}
			try
			{
				await db.SaveChangesAsync();
			}
			catch (DbUpdateConcurrencyException)
			{
				if (!NamespaceExists(key))
				{
					return NotFound();
				}
				else
				{
					throw;
				}
			}
			return Updated(entity);
		}
开发者ID:WorkMarketingNet,项目名称:WMN.Translate,代码行数:36,代码来源:NamespacesController.cs

示例4: Put

        public IHttpActionResult Put(int key, Delta<DateAndTimeOfDayModel> dt)
        {
            Assert.Equal(new[] { "Birthday", "CreatedTime" }, dt.GetChangedPropertyNames());

            // Birthday
            object value;
            bool success = dt.TryGetPropertyValue("Birthday", out value);
            Assert.True(success);
            DateTime dateTime = Assert.IsType<DateTime>(value);
            Assert.Equal(DateTimeKind.Unspecified, dateTime.Kind);
            Assert.Equal(new DateTime(2199, 1, 2), dateTime);

            // CreatedTime
            success = dt.TryGetPropertyValue("CreatedTime", out value);
            Assert.True(success);
            TimeSpan timeSpan = Assert.IsType<TimeSpan>(value);
            Assert.Equal(new TimeSpan(0, 14, 13, 15, 179), timeSpan);
            return Updated(dt);
        }
开发者ID:genusP,项目名称:WebApi,代码行数:19,代码来源:DateAndTimeOfDayWithEfTest.cs

示例5: Patch

		public async Task<IHttpActionResult> Patch([FromODataUri] int key, Delta<Translation> translation, [ValueProvider(typeof(CultureValueProviderFactory))] string culture = "en-US")
		{
			if (!ModelState.IsValid)
			{
				return BadRequest(ModelState);
			}
			var entity = (from term in db.Terms.Where(t => t.Id == key)
				join termTranslation in db.TermTranslations.Where(t => t.Culture == culture)
					on term.Id equals termTranslation.TermId
				select term).Include(t => t.Translations).SingleOrDefault();

            if (entity == null)
			{
				return NotFound();
			}

			var translationEntity =  translation.GetEntity();
			var tr = entity.Translations.FirstOrDefault();
			foreach (var property in translation.GetChangedPropertyNames())
			{
				// term
				if (property == nameof(entity.Key))
				{
					entity.Key = translationEntity.Key;
				} else if (property == nameof(entity.DictionryId))
				{
					entity.DictionryId = translationEntity.NamespaceId;
				}

				// term translation
				if (property == nameof(tr.Value))
				{
					tr.Value = translationEntity.Value;
				}
			}
			try
			{
				await db.SaveChangesAsync();
			}
			catch (DbUpdateConcurrencyException)
			{
				if (!TranslationExists(key))
				{
					return NotFound();
				}
				else
				{
					throw;
				}
			}
			return Updated(entity);
		}
开发者ID:WorkMarketingNet,项目名称:WMN.Translate,代码行数:52,代码来源:TranslationsController.cs

示例6: Put

        public IHttpActionResult Put(int key, Delta<DateTimeModel> dt)
        {
            Assert.Equal(new[] { "BirthdayA", "BirthdayB" }, dt.GetChangedPropertyNames());

            object value;
            bool success = dt.TryGetPropertyValue("BirthdayA", out value);
            Assert.True(success);
            DateTime dateTime = Assert.IsType<DateTime>(value);
            Assert.Equal(DateTimeKind.Unspecified, dateTime.Kind);
            Assert.Equal(new DateTime(2098, 12, 31, 17, 2, 3), dateTime);

            success = dt.TryGetPropertyValue("BirthdayB", out value);
            Assert.True(success);
            Assert.Null(value);

            return Updated(dt);
        }
开发者ID:billwaddyjr,项目名称:WebApi,代码行数:17,代码来源:DateTimeTest.cs


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