本文整理汇总了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));
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}