Ejemplo n.º 1
0
        private static void RealWorldScenario()
        {
            var rnd = new Random();

            using (var manager = new SimpleItemFirstLevelCacheManager())
            {
                for (int i = 0; i < MaxItemCount; i++)
                {
                    var entity = new SimpleItem()
                    {
                        ContainerName = "TestContainer",
                        FieldName     = "TestField",
                        FieldValue    = "Test"
                    };
                    manager.Add(entity);
                }

                for (int i = 0; i < MaxItemCount; i++)
                {
                    var entity = new SimpleItem()
                    {
                        PkId          = i + 1,
                        ContainerName = "TestContainer" + i,
                        FieldName     = "TestField" + i,
                        FieldValue    = "Test" + i
                    };
                    manager.Update(entity);
                }

                //manager.Refresh(true);


                for (int i = 0; i < MaxItemCount / 10; i++)
                {
                    var t = rnd.Next(MaxItemCount);
                    try
                    {
                        manager.Delete(i);
                    }
                    // ReSharper disable once EmptyGeneralCatchClause
                    catch { }
                }

                var result = manager.AsQueryable().Take(MaxItemCount).ToList();
                foreach (var simpleItem in result)
                {
                    Console.WriteLine("PkId: {0}, ContainerName: {1}, FieldName: {2}, FieldValue: {3}", simpleItem.PkId, simpleItem.ContainerName, simpleItem.FieldName, simpleItem.FieldValue);
                }
            }
        }
Ejemplo n.º 2
0
        private static void RealWorldScenario()
        {
            var rnd = new Random();
            using (var manager = new SimpleItemFirstLevelCacheManager())
            {
                for (int i = 0; i < MaxItemCount; i++)
                {
                    var entity = new SimpleItem()
                    {
                        ContainerName = "TestContainer",
                        FieldName = "TestField",
                        FieldValue = "Test"
                    };
                    manager.Add(entity);
                }

                for (int i = 0; i < MaxItemCount; i++)
                {
                    var entity = new SimpleItem()
                    {
                        PkId = i + 1,
                        ContainerName = "TestContainer" + i,
                        FieldName = "TestField" + i,
                        FieldValue = "Test" + i
                    };
                    manager.Update(entity);
                }

                //manager.Refresh(true);

                for (int i = 0; i < MaxItemCount / 10; i++)
                {
                    var t = rnd.Next(MaxItemCount);
                    try
                    {
                        manager.Delete(i);
                    }
                    // ReSharper disable once EmptyGeneralCatchClause
                    catch { }
                }

                var result = Queryable.Take(manager.AsQueryable(), MaxItemCount).ToList();
                foreach (var simpleItem in result)
                {
                    Console.WriteLine("PkId: {0}, ContainerName: {1}, FieldName: {2}, FieldValue: {3}", simpleItem.PkId, simpleItem.ContainerName, simpleItem.FieldName, simpleItem.FieldValue);
                }
            }
        }