Inserting extra data into linq in sql partial class

I have an L2S generated class called Accounts, I have an L2S class called UsersInAccounts. I need to add a function call. AddUserToAccount (accountid, userid) should / should this function be added to the partial Accounts class that I created or partial classes used to get data and not edit data

 public partial class Account
    {

        public void addUser(Guid userid)
        {
           // code
        }
    }

      

0


a source to share


1 answer


I don't think what you are doing is the problem. In your code, you will probably have an instance of an account that you want to do something with in order to do this:

Account theAccountIWant = GetTheAccount();
theAccountIWant.addUser(myUsersGUID);

      



... seems pretty intuitive. It might be an idea to make some capture errors inside your addUser method and pass some kind of success status, but that's another discussion.

edit: As you were advised, if you then retrieve the User object and want to bind it to an account using the AccountUsers property, then it's useless unless you pass in the DataContext.

0


a source







All Articles