Ejemplo n.º 1
0
        public static TempContext <ShapeBuilder> BorrowShapeBuilder(out ShapeBuilder shapeBuilder)
        {
            if (!Temp <ShapeBuilder> .IsInit())
            {
                Temp <ShapeBuilder> .SetNewHandler(
                    () => new ShapeBuilder(),
                    f => f.Reset());
            }

            TempContext <ShapeBuilder> context = Temp <ShapeBuilder> .Borrow(out shapeBuilder);

            shapeBuilder.InitVxs();//make it ready-to-use
            return(context);
        }
        // GET: Home
        public ActionResult Index()
        {
            TempContext   context = new TempContext();
            List <Person> persons = null;

            using (context)
            {
                persons = context.Persons.Include(x => x.Address.City.Country).ToList();
            }

            ViewBag.AllPersons = persons;
            //ViewData["persons"] = persons;

            return(View());
        }
Ejemplo n.º 3
0
        public async Task MakeTest()
        {
            using var tempDir       = new TempDir();
            using var contextHolder = TempContext.Create();
            var ctx = contextHolder.Object;

            var outputStream = new MemoryStream();

            var res = await Tar.Make(outputStream, ctx, new[] { tempDir.Path });

            var outputRes = outputStream.ToArray();

            using var zip = new ZipArchive(outputRes.ToStream(), ZipArchiveMode.Read);

            Assert.True(zip.Entries.Count == 4);
        }
Ejemplo n.º 4
0
        public override async Task UpgradeAsync(DbTransaction?transaction = null, CancellationToken token = default)
        {
            var tempContextOptionsBuilder = new DbContextOptionsBuilder <TempContext>();

            tempContextOptionsBuilder.UseNpgsql(DbProvider.Connection);

            var anotherTempContextOptionsBuilder = new DbContextOptionsBuilder <AnotherTempContext>();

            anotherTempContextOptionsBuilder.UseNpgsql(DbProvider.Connection);

            using (var tempContext = new TempContext(tempContextOptionsBuilder.Options))
                using (var anotherContext = new AnotherTempContext(anotherTempContextOptionsBuilder.Options))
                {
                    // tempContext.Database.UseTransaction(transaction);
                    // anotherContext.Database.UseTransaction(transaction);

                    var request1 = new BackgroundProcessorRequestEntity
                    {
                        CreatedUtc         = DateTime.Now,
                        TimeZoneId         = "temo",
                        Type               = 1,
                        State              = 1,
                        UserId             = 1,
                        ProjectId          = 1,
                        RequestCultureName = "ru"
                    };
                    var request2 = new BackgroundProcessorRequestEntity
                    {
                        CreatedUtc         = DateTime.Now,
                        TimeZoneId         = "temo",
                        Type               = 1,
                        State              = 1,
                        UserId             = 1,
                        ProjectId          = 1,
                        RequestCultureName = "ru"
                    };

                    tempContext.Requests.Add(request1);
                    anotherContext.Requests.Add(request2);

                    await tempContext.SaveChangesAsync();

                    await anotherContext.SaveChangesAsync();
                }
        }
        public ActionResult ShowDetail(int id)
        {
            TempContext context = new TempContext();

            Person person = null;

            using (context)
            {
                person = (from p in context.Persons
                          .Include(x => x.Address.City.Country)
                          where p.PersonId == id
                          select p).FirstOrDefault();
            }

            ViewBag.PersonDetail = person;

            return(PartialView("_DetailView"));
        }
 protected BaseController()
 {
     db              = new TempContext();
     Blog            = db.Blogs.FirstOrDefault();
     Ability         = db.Abilities.FirstOrDefault();
     AboutSpec       = db.AboutSpecs.FirstOrDefault();
     Comment         = db.Comments.FirstOrDefault();
     Portfolio       = db.Portfolios.FirstOrDefault();
     HomeImage       = db.HomeImages.FirstOrDefault();
     Position        = db.Positions.FirstOrDefault();
     Post            = db.Posts.FirstOrDefault();
     SecondBlog      = db.SecondBlogs.FirstOrDefault();
     Service         = db.Services.FirstOrDefault();
     Speciality      = db.Specialities.FirstOrDefault();
     Team            = db.Teams.FirstOrDefault();
     Testimonial     = db.Testimonials.FirstOrDefault();
     Setting         = db.Settings.FirstOrDefault();
     ViewBag.Setting = db.Settings.FirstOrDefault();
 }
Ejemplo n.º 7
0
 public Repository(TempContext dbContext)
 {
     _dbContext = dbContext;
 }