Exemplo n.º 1
0
        public static bool TryParse(string value, out LocalTime result)
        {
            result = default;

            if (!TryParse(value, out DateTime date))
            {
                return(false);
            }

            result = CassandraPrimitivesExtensions.ToLocalTime(date);
            return(true);
        }
Exemplo n.º 2
0
 public SampleDataBase()
 {
     serializer = new Serializer(new AllPropertiesExtractor());
     fixture    = new Fixture();
     fixture.Register((DateTime date) => date.ToLocalDate());
     fixture.Register((DateTime time) => CassandraPrimitivesExtensions.ToLocalTime(time));
     fixture.Register((int i) => i % 2 == 0
                                     ? (BaseClass) new ChildClass {
         Int = i
     }
                                     : new ChildClass2
     {
         String  = i.ToString(),
         Strings = Enumerable.Range(0, 10).Select(x => x.ToString()).ToArray()
     });
 }
Exemplo n.º 3
0
        private void CreateTable <T>(CqlDbContext context, int count)
            where T : class
        {
            context.DropTable <T>();
            var table = context.GetTable <T>();

            var fixture = new Fixture();

            fixture.Register((DateTime dt) => dt.ToLocalDate());
            fixture.Register((DateTime dt) => CassandraPrimitivesExtensions.ToLocalTime(dt));

            for (var i = 0; i < count; i++)
            {
                table.Insert(Modify <T>(fixture)).SetTimestamp(DateTimeOffset.UtcNow).Execute();
            }
        }
Exemplo n.º 4
0
        private static void CreateTable <T>(ISession session, int count)
        {
            var table = new Table <T>(session);

            session.Execute($"DROP TABLE IF EXISTS {table.KeyspaceName}.{table.Name};");
            table.CreateIfNotExists();

            var fixture = new Fixture();

            fixture.Register((DateTime dt) => dt.ToLocalDate());
            fixture.Register((DateTime dt) => CassandraPrimitivesExtensions.ToLocalTime(dt));

            for (var i = 0; i < count; i++)
            {
                table.Insert(fixture.Create <T>()).SetTimestamp(DateTimeOffset.UtcNow).Execute();
            }
        }