English 中文(简体)
Cannot Save Nullable<bool>,《Null》
原标题:Cannot Save Nullable<bool> to Azure Table when its Null

例如,我有一个<编码>bool? 现况: c

当<代码>Status =真实/false时,它可以节省到桌旁,没有问题。

But when Stats = null, it cannot save(update) to Azure table, the column still keeps the old value

I guess it might because Azure table does not have a scheme, but whats the solution?

如何拯救<>null至overwrite原始价值?

EDIT, the code

类似数据:

public class someEntity : TableServiceEntity
{
    public bool? Status { get; set; }
}

update like this:

tableContext.AttachTo("sometable", someEntity);
tableContext.UpdateObject(someEntity);
tableContext.SaveChangesWithRetries(SaveChangesOptions.Batch & SaveChangesOptions.ReplaceOnUpdate);

(I Trial AttachTo with >*>, as etag,tries out SaveChangesOptions, both work)

SORRY for my stupid, should be this code, then works

tableContext.SaveChangesWithRetries(SaveChangesOptions.Batch | SaveChangesOptions.ReplaceOnUpdate);
最佳回答

正如“Matthew”所建议的,我在此作回答。

非常简单,使用:

tableContext.SaveChangesWithRetries(SaveChangesOptions.Batch | SaveChangesOptions.ReplaceOnUpdate);

关于多种选择,使用 (or), not & (and). Reason

SaveChangesOptions.ReplaceOnUpdate = true means the whole entity will be replaced SaveChangesOptions.ReplaceOnUpdate = false, means merge, the old data will be kept

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签