예제 #1
0
        private const string ConnectionString = "server=localhost;user id=root;persistsecurityinfo=True;database=supervkappdb"; //

        #endregion Fields

        #region Methods

        static void Main(string[] args)
        {
            var nhibernatehelper = new NHibernateHelper(ConnectionString);
            var unitofwork = new UnitOfWork(nhibernatehelper.SessionFactory);

            //попробуем чонить добавить в бд

            var user = new UserDomain
            {
                //Id = "egorveidt", какого черта я сделал интовый айдишник, фаак !!! переделать
                FirstName = "Егор",
                LastName = "Пичугов",
                Age = 21,
                Male = true
            };
            var post = new PostDomain
            {
                Date = new DateTime(2016, 01, 07),
                Text = "test text exst",
            };

            post.AddSnapshot(new PostSnapshotDomain()
            {
                CountComments = 1,
                CountLikes = 10,
                CountReposts = 2,
                Date = new DateTime(2016, 01, 07)
            });

            user.AddPost(post);
            var userRepository = new Repository<UserDomain>(unitofwork.Session);
            userRepository.SaveOrUpdate(user);
            unitofwork.Commit();
        }
예제 #2
0
 public virtual void AddUser(UserDomain user)
 {
     Users.Add(user);
     user.LoginUsers.Add(this);
 }
예제 #3
0
 public virtual void SetOwner(UserDomain owner)
 {
     owner.AddPost(this);
 }
예제 #4
0
 public virtual void SetOwner(UserDomain owner)
 {
     owner.AddPost(this);
 }
예제 #5
0
 public virtual void AddUser(UserDomain user)
 {
     Users.Add(user);
     user.LoginUsers.Add(this);
 }