Example #1
0
        public PocoData(Type pocoType, string tableName, string keyspaceName, LookupKeyedCollection <string, PocoColumn> columns,
                        string[] partitionkeys, Tuple <string, SortOrder>[] clusteringKeys, bool caseSensitive, bool compact, bool allowFiltering)
        {
            if (partitionkeys == null)
            {
                throw new ArgumentNullException("partitionkeys");
            }
            if (clusteringKeys == null)
            {
                throw new ArgumentNullException("clusteringKeys");
            }
            PocoType             = pocoType ?? throw new ArgumentNullException("pocoType");
            TableName            = tableName ?? throw new ArgumentNullException("tableName");
            Columns              = columns ?? throw new ArgumentNullException("columns");
            CaseSensitive        = caseSensitive;
            CompactStorage       = compact;
            AllowFiltering       = allowFiltering;
            KeyspaceName         = keyspaceName;
            _columnsByMemberName = columns.ToDictionary(c => c.MemberInfo.Name, c => c);
            PartitionKeys        = partitionkeys.Where(columns.Contains).Select(key => columns[key]).ToList();
            ClusteringKeys       = clusteringKeys.Where(c => columns.Contains(c.Item1)).Select(c => Tuple.Create(columns[c.Item1], c.Item2)).ToList();
            _primaryKeys         = new HashSet <string>(PartitionKeys.Select(p => p.ColumnName).Concat(ClusteringKeys.Select(c => c.Item1.ColumnName)));

            MissingPrimaryKeyColumns = new List <string>();
            if (PartitionKeys.Count != partitionkeys.Length)
            {
                MissingPrimaryKeyColumns.AddRange(partitionkeys.Where(k => !columns.Contains(k)));
            }
            if (ClusteringKeys.Count != clusteringKeys.Length)
            {
                MissingPrimaryKeyColumns.AddRange(partitionkeys.Where(k => !columns.Contains(k)));
            }
        }
Example #2
0
        public PocoData(Type pocoType, string tableName, string keyspaceName, LookupKeyedCollection<string, PocoColumn> columns,
                        string[] partitionkeys, Tuple<string, SortOrder>[] clusteringKeys, bool caseSensitive, bool compact, bool allowFiltering)
        {
            if (pocoType == null) throw new ArgumentNullException("pocoType");
            if (tableName == null) throw new ArgumentNullException("tableName");
            if (columns == null) throw new ArgumentNullException("columns");
            if (partitionkeys == null) throw new ArgumentNullException("partitionkeys");
            if (clusteringKeys == null) throw new ArgumentNullException("clusteringKeys");
            PocoType = pocoType;
            TableName = tableName;
            Columns = columns;
            CaseSensitive = caseSensitive;
            CompactStorage = compact;
            AllowFiltering = allowFiltering;
            KeyspaceName = keyspaceName;
            _columnsByMemberName = columns.ToDictionary(c => c.MemberInfo.Name, c => c);
            PartitionKeys = partitionkeys.Where(columns.Contains).Select(key => columns[key]).ToList();
            ClusteringKeys = clusteringKeys.Where(c => columns.Contains(c.Item1)).Select(c => Tuple.Create(columns[c.Item1], c.Item2)).ToList();
            _primaryKeys = new HashSet<string>(PartitionKeys.Select(p => p.ColumnName).Concat(ClusteringKeys.Select(c => c.Item1.ColumnName)));

            MissingPrimaryKeyColumns = new List<string>();
            if (PartitionKeys.Count != partitionkeys.Length)
            {
                MissingPrimaryKeyColumns.AddRange(partitionkeys.Where(k => !columns.Contains(k)));
            }
            if (ClusteringKeys.Count != clusteringKeys.Length)
            {
                MissingPrimaryKeyColumns.AddRange(partitionkeys.Where(k => !columns.Contains(k)));
            }
        }
Example #3
0
        public PocoData(Type pocoType, string tableName, LookupKeyedCollection <string, PocoColumn> columns,
                        HashSet <string> primaryKeyColumns)
        {
            if (pocoType == null)
            {
                throw new ArgumentNullException("pocoType");
            }
            if (tableName == null)
            {
                throw new ArgumentNullException("tableName");
            }
            if (columns == null)
            {
                throw new ArgumentNullException("columns");
            }
            if (primaryKeyColumns == null)
            {
                throw new ArgumentNullException("primaryKeyColumns");
            }
            PocoType          = pocoType;
            TableName         = tableName;
            Columns           = columns;
            PrimaryKeyColumns = primaryKeyColumns;

            MissingPrimaryKeyColumns = PrimaryKeyColumns.Where(colName => Columns.Contains(colName) == false).ToArray();
        }
Example #4
0
 /// <summary>
 /// Adds a definition to the local state in case no definition was explicitly defined.
 /// Used when the local default (AttributeBasedTypeDefinition) is not valid for a given type.
 /// </summary>
 public void AddDefinitionDefault(Type type, Func <ITypeDefinition> definitionHandler)
 {
     //In case there isn't already Poco information in the local cache.
     if (_predefinedTypeDefinitions.Contains(type))
     {
         return;
     }
     _cache.GetOrAdd(type, t => CreatePocoData(t, definitionHandler()));
 }