public IFindFluent <T, T> Find(string FieldName, object Value)
        {
            LastQuery = MongoQuery <T> .Eq(typeof(T).Name, FieldName, Value);

            Cursor = GetCollection().Find <T>(LastQuery);
            return(Cursor);
        }
        public IFindFluent <T, T> Find(Expression <Func <T, object> > Field, object Value)
        {
            LastQuery = MongoQuery <T> .Eq(Field, Value);

            Cursor = GetCollection().Find <T>(LastQuery);
            return(Cursor);
        }
Exemple #3
0
        public static void MongoFind <T>(this List <T> List, string FieldName, object Value) where T : MongoMapper <T>
        {
            List.Clear();
            var col = new MongoMapperCollection <T>();

            col.Find(MongoQuery <T> .Eq(typeof(T).Name, FieldName, Value));
            List.AddRange(col.ToList());
        }
Exemple #4
0
        public static void MongoFind <T>(this List <T> List, Expression <Func <T, object> > Field, object Value) where T : MongoMapper <T>
        {
            List.Clear();
            var col = new MongoMapperCollection <T>();

            col.Find(MongoQuery <T> .Eq(Field, Value));
            List.AddRange(col.ToList());
        }
Exemple #5
0
        private static void CheckRelation(object Sender, MongoRelation Relation, bool FromUp)
        {
            Dictionary <string, object> fieldValues = new Dictionary <string, object>();

            for (int index = 0; index < Relation.CurrentFieldNames.Length; index++)
            {
                string currentFieldName  = Relation.CurrentFieldNames[index];
                string relationFieldName = Relation.RelationFieldNames[index];
                object v = ReflectionUtility.GetPropertyValue(Sender, currentFieldName);
                fieldValues.Add(relationFieldName, v);
            }

            if (fieldValues.All(V => V.Value == null))
            {
                return;
            }


            var filters = fieldValues.Select(CurrentFieldvalue => MongoQuery <BsonDocument> .Eq(Relation.RelationObjectName, CurrentFieldvalue.Key, CurrentFieldvalue.Value)).ToList();

            var relationCollection = CollectionsManager.GetPrimaryCollection <BsonDocument>(Relation.RelationObjectName);

            var documentCount = relationCollection.CountAsync(Builders <BsonDocument> .Filter.And(filters)).Result;

            bool okRelation = FromUp ? documentCount != 0 : documentCount == 0;

            if (!okRelation)
            {
                if (FromUp)
                {
                    throw new ValidateUpRelationException(string.Join(",", filters.FilterToJson()));
                }

                throw new ValidateDownRelationException(string.Join(",", filters.FilterToJson()));
            }
        }
Exemple #6
0
 public static FilterDefinition <T> RegEx(Expression <Func <T, object> > field, object Value)
 {
     return(MongoQuery <T> .RegEx(typeof(T).Name, ReflectionUtility.GetPropertyName(field), Value.ToString()));
 }
Exemple #7
0
 public static FilterDefinition <T> Gt(Expression <Func <T, object> > Field, object Value)
 {
     return(MongoQuery <T> .Gt(typeof(T).Name, ReflectionUtility.GetPropertyName(Field), Value));
 }