예제 #1
0
        protected Visit InsertVisit(Member member)
        {
            DateTime visitTime = DateTime.Now - TimeSpan.FromHours(_random.NextDouble() * 24);

            Visit visit = new Visit(member.Id)
            {
                VisitTime = visitTime,
            };

            visit.Insert <Visit>(_mongoConnection);

            return(visit);
        }
예제 #2
0
        public void InsertIdentity(TEntity entity)
        {
            Queue.Sql = new StringBuilder();
            var strinsertAssemble = Visit.Insert(entity);

            var map = TableMapCache.GetMap(entity);

            var indexHaveValue = map.GetModelInfo().Key != null && map.GetModelInfo().Key.GetValue(entity, null) != null;

            if (!string.IsNullOrWhiteSpace(map.IndexName) && indexHaveValue)
            {
                Queue.Sql.AppendFormat("SET IDENTITY_INSERT {0} ON ; ", TableName);
            }

            Queue.Sql.AppendFormat("INSERT INTO {0} {1};SELECT @@IDENTITY;", TableName, strinsertAssemble);

            if (!string.IsNullOrWhiteSpace(map.IndexName) && indexHaveValue)
            {
                Queue.Sql.AppendFormat("; SET IDENTITY_INSERT {0} OFF; ", TableName);
            }
        }