Exemple #1
0
        private Option <IDatabaseKey> LoadPrimaryKey()
        {
            var primaryKey = TypeProvider.PrimaryKey;

            if (primaryKey == null)
            {
                return(Option <IDatabaseKey> .None);
            }

            var pkColumns = primaryKey.Columns.Select(GetColumn).ToList();

            var keyName = Dialect.GetAliasOrDefault(primaryKey.Property !);
            var dbKey   = new ReflectionKey(keyName, primaryKey.KeyType, pkColumns);

            return(Option <IDatabaseKey> .Some(dbKey));
        }
Exemple #2
0
        private IReadOnlyDictionary <Identifier, IDatabaseKey> LoadUniqueKeys()
        {
            var result = new Dictionary <Identifier, IDatabaseKey>();

            var uniqueKeys = TypeProvider.UniqueKeys;

            if (uniqueKeys.Empty())
            {
                return(result);
            }

            foreach (var uniqueKey in uniqueKeys)
            {
                var ukColumns = uniqueKey.Columns.Select(GetColumn).ToList();
                var keyName   = Dialect.GetAliasOrDefault(uniqueKey.Property !);
                var uk        = new ReflectionKey(keyName, uniqueKey.KeyType, ukColumns);
                uk.Name.IfSome(name => result[name.LocalName] = uk);
            }

            return(result);
        }