LINQ to Sharepoint - User field

1.2k Views Asked by At

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?

1

There are 1 best solutions below

0
Michal On BEST ANSWER

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.