Exemplo n.º 1
0
        public static List <KeyValuePair <int, Association> > GetAssociationListByTag(IEnumerable <Tag> findTagList, SqlConnection sqlConnection, MongoConnection mongoConnection)
        {
            List <KeyValuePair <int, Association> > result = new List <KeyValuePair <int, Association> >();
            var collection = mongoConnection.GetCollection("Association");
            var documents  = collection.Find(new BsonDocument()).ToList();

            foreach (BsonDocument document in documents)
            {
                int counter = 0;
                foreach (BsonDocument tag in document.GetValue("Tags").AsBsonArray)
                {
                    foreach (Tag findTag in findTagList)
                    {
                        if (findTag._id.CompareTo(tag.GetValue("$id").AsObjectId) == 0)
                        {
                            counter++;
                            break;
                        }
                    }
                }
                Association association = new Association(sqlConnection);
                association.GetById(document.GetValue("_id").AsObjectId, mongoConnection);
                result.Add(new KeyValuePair <int, Association>(counter, association));
            }
            return(result);
        }
Exemplo n.º 2
0
        public void GetByContent(string content, MongoConnection connection)
        {
            Connection = connection;
            Collection = Connection.GetCollection(collectionName);
            var filter = Builders <BsonDocument> .Filter.Eq("Content", content);

            var document = Collection.Find(filter).First();

            _id     = document.GetValue("_id").AsObjectId;
            Content = content;
        }
Exemplo n.º 3
0
        public void GetByLink(string link, MongoConnection connection)
        {
            Connection = connection;
            Collection = Connection.GetCollection(collectionName);
            var filter = Builders <BsonDocument> .Filter.Eq("Link", link);

            var document = Collection.Find(filter).First();

            _id     = document.GetValue("_id").AsObjectId;
            Name    = document.GetValue("Name").AsString;
            Link    = link;
            Extract = document.GetValue("Extract").AsString;
        }