コード例 #1
0
 public void Update(Dictionary <string, List <IValidator> > conditions, List <object> row)
 {
     if (!ValidateDataTypes(row))
     {
         throw new DataValueTypeException("Incorrect data types! Expected: " +
                                          Entity.Schema.Columns.Select(x => DataValueType.GetType(x.DataValueType).Name).Aggregate((x, y) => $"{x}, {y}"));
     }
     _storage.Update(Entity, conditions, row);
 }
コード例 #2
0
 public void Insert(List <object> row)
 {
     row.Insert(0, Guid.NewGuid());
     if (!ValidateDataTypes(row))
     {
         throw new DataValueTypeException("Incorrect data types! Expected: " +
                                          Entity.Schema.Columns.Select(x => DataValueType.GetType(x.DataValueType).Name).Aggregate((x, y) => $"{x}, {y}"));
     }
     _storage.Insert(Entity, new List <List <object> > {
         row
     });
 }
コード例 #3
0
 public void Update(List <List <object> > rows)
 {
     for (int i = 0; i < rows.Count; i++)
     {
         if (!ValidateDataTypes(rows[i].ToList()))
         {
             throw new ArgumentException("Incorrect data types! Expected: " +
                                         Entity.Schema.Columns.Select(x => DataValueType.GetType(x.DataValueType).Name).Aggregate((x, y) => $"{x}, {y}"));
         }
     }
     _storage.Update(Entity, rows);
 }
コード例 #4
0
        public void InsertRange(List <List <object> > rows)
        {
            rows.ForEach((item) =>
            {
                item.Insert(0, Guid.NewGuid());
            });
            if (!rows.All(x => ValidateDataTypes(x)))
            {
                throw new DataValueTypeException("Incorrect data types! Expected: " +
                                                 Entity.Schema.Columns.Select(x => DataValueType.GetType(x.DataValueType).Name).Aggregate((x, y) => $"{x}, {y}"));
            }

            _storage.Insert(Entity, rows);
        }
コード例 #5
0
        public override List <IValidator> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            var jsonObject = JsonDocument.ParseValue(ref reader);

            var array  = JsonSerializer.Deserialize <JsonElement>(jsonObject.RootElement.GetString());
            var result = array.EnumerateArray().Select(x =>
            {
                var validatorType       = Type.GetType(x.GetProperty("type").GetString());
                var element             = JsonSerializer.Deserialize(x.GetRawText(), validatorType);
                IValidator validator    = (IValidator)element;
                validator.ComparsonType = x.GetProperty("comparsonType").GetInt32();

                var valueType   = DataValueType.GetType(new Guid(x.GetProperty("dataValueTypeId").GetString()));
                validator.Value = JsonSerializer.Deserialize(x.GetProperty("value").GetRawText(), valueType);
                validator.Init();

                return((IValidator)element);
            });

            return(result.ToList());
        }
コード例 #6
0
        public List <List <object> > InnerJoin(Entity joinableEntity, Tuple <string, string> joinableColumns, bool showSystemColumns = true)
        {
            var firstColumn  = Entity.Schema.Columns.Find(item => item.Name == joinableColumns.Item1);
            var secondColumn = joinableEntity.Schema.Columns.Find(item => item.Name == joinableColumns.Item2);

            if (firstColumn.DataValueType != secondColumn.DataValueType)
            {
                throw new DataValueTypeException("Column types selected for join operation doesnt match");
            }
            int indexOfFirstColumnEntity  = Entity.Schema.Columns.IndexOf(firstColumn),
                indexOfSecondColumnEntity = joinableEntity.Schema.Columns.IndexOf(secondColumn);

            var type = DataValueType.GetType(firstColumn.DataValueType);

            var result = from first in _storage.Select(Entity, showSystemColumns).ToList()
                         join second in _storage.Select(joinableEntity, showSystemColumns).ToList()
                         on first[indexOfFirstColumnEntity].ToString() equals second[indexOfSecondColumnEntity].ToString()
                         select first.Concat(second).ToList();

            return(result.ToList());
        }