LINQ to Sharepoint - 用户字段
我正在使用 LINQ to Sharepoint,并且在保存具有用户字段的实体时遇到了大问题。 SPMetal 为我生成了类似字符串属性的用户字段,所以我尝试做这样的事情:
SomeEntity e = new SomeEntity() { ..., User = user.ID, ... };
dataContext.XXX.InsertOnSubmit(e);
dataContext.SubmitChanges();
用户变量是 SPUser 的类型,我也尝试了 User = user.Sid、user.LoginName 和 id:#domain\login name 但这一切都没有不工作。用户字段始终为空。
请问有人知道如何正确保存带有用户字段的项目吗?
I'm using LINQ to Sharepoint and I've got big problem with saving entity which have user field. SPMetal generated me User field like string property, so I try tu do something like this:
SomeEntity e = new SomeEntity() { ..., User = user.ID, ... };
dataContext.XXX.InsertOnSubmit(e);
dataContext.SubmitChanges();
user variable is type of SPUser, I tried also User = user.Sid, user.LoginName and id:#domain\login name but anything of this didn't working. User field is always empty.
Please do anybody know how to correctly save item with user field?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想通了。我并不太复杂:)。如果有人遇到问题,SPMetal 还会生成必须在用户 ID 上设置的属性 UserID。不需要设置字符串用户属性。
I figured it out. I wasn't too complicated :). If somebody has the some problem, SPMetal generates also property UserID which has to be set on user id. It's not needed to set up string User property.