コード例 #1
0
        public NoSqlRepository(NoSQLContext context, Options options, ISerializerFactory serializerFactory, ITypeVersioner versioner)
        {
            //set the external context
            this.Context = context;

            this.Options      = options;
            SerializerFactory = serializerFactory;
            TypeVersioner     = versioner;
        }
コード例 #2
0
        public static void UpdateLastTweetId(ObjectId _id, decimal _tweetId)
        {
            IMongoCollection <LastTweetInfo> collection = new NoSQLContext().lastTweetCollection;

            collection.ReplaceOne(b => b.TweetId != 0, new LastTweetInfo()
            {
                Id = _id, TweetId = _tweetId
            });
        }
コード例 #3
0
        public static List <Tweets> GetAllTweets(DateTime fromDate, DateTime toDate, string sentType)
        {
            IMongoCollection <Tweets> collection = new NoSQLContext().twitterCollection;

            return(collection.Find(b => !string.IsNullOrEmpty(b.Text) &&
                                   ((b.sentiment.SentimentType.Equals(sentType) && !string.IsNullOrEmpty(sentType)) || string.IsNullOrEmpty(sentType)) &&
                                   ((b.CreatedDate >= fromDate && fromDate != DateTime.MinValue) || fromDate == DateTime.MinValue) &&
                                   ((b.CreatedDate <= toDate && toDate != DateTime.MinValue) || toDate == DateTime.MinValue)
                                   ).SortByDescending(s => s.CreatedDate).ToList <Tweets>());
        }
コード例 #4
0
        public static void UpdateResponseStatus(decimal _tweetId, string status)
        {
            IMongoCollection <Tweets> collection = new NoSQLContext().twitterCollection;


            Tweets tweet = new Tweets();

            tweet = collection.Find(b => b.TweetId == _tweetId).ToList <Tweets>().First();
            tweet.ResponseStatus = status;

            collection = new NoSQLContext().twitterCollection;
            collection.ReplaceOne(b => b.TweetId == _tweetId, tweet);
        }
コード例 #5
0
        public static LastTweetInfo GetLastTweetId()
        {
            IMongoCollection <LastTweetInfo> collection = new NoSQLContext().lastTweetCollection;

            return(collection.Find(b => b.TweetId != 0).First <LastTweetInfo>());
        }
コード例 #6
0
        public static void InsertSingleTweet(Tweets tweet)
        {
            IMongoCollection <Tweets> collection = new NoSQLContext().twitterCollection;

            collection.InsertOne(tweet);
        }
コード例 #7
0
ファイル: Store.cs プロジェクト: gragonvlad/NoSql
 private Store(NoSQLContext context, Options options, ISerializerFactory serializerFactory, ITypeVersioner versioner)
     : base(context, options, serializerFactory, versioner)
 {
     this._context = context;
 }
コード例 #8
0
ファイル: Store.cs プロジェクト: gragonvlad/NoSql
 private Store(NoSQLContext context)
     : this(context, new Options(), new DefaultSerializerFactory(), new TypeVersioner())
 {
 }
コード例 #9
0
ファイル: NoSqlRepository^T.cs プロジェクト: gragonvlad/NoSql
 public NoSqlRepository(NoSQLContext context, Options options, ISerializerFactory serializerFactory, ITypeVersioner versioner)
 {
     _store = new NoSqlRepository(context, options, serializerFactory, versioner);
 }
コード例 #10
0
ファイル: NoSqlRepository^T.cs プロジェクト: gragonvlad/NoSql
 public NoSqlRepository(NoSQLContext context)
     : this(context, new Options(), new DefaultSerializerFactory(), new TypeVersioner())
 {
 }
コード例 #11
0
        static void Main(string[] args)
        {
            try
            {
                YoIt f**k = new YoIt();
                f**k.Yo();

                DbInitializationTools.DbInitializerStrategyFactory("CreateIfChanged");

                Console.WriteLine("Clear database?");
                var instruction = Console.ReadKey();
                if (instruction.Key == ConsoleKey.Y)
                {
                    using (var context = new NoSQLContext())
                    {
                        context.Database.ExecuteSqlCommand("Delete from Store");
                        context.Database.ExecuteSqlCommand("Delete from typeversion");
                        context.Database.ExecuteSqlCommand("Delete from StoreArchive");
                    }
                }

                //DoIt();
                //MigrationsFuck();
                //return;

                // Temp test of the system
                Guid id1, id2;
                using (var context = new NoSQLContext())
                {
                    NoSqlRepository s = new NoSqlRepository(context);

                    id1 = s.Create(@"P&P test 1");
                    id2 = s.Create(@"P&P test 2");

                    context.SaveChanges();
                }

                using (var context = new NoSQLContext())
                {
                    NoSqlRepository <string> s = new NoSqlRepository <string>(context);

                    var foo = s.Retrieve(id1);
                    var bar = s.Retrieve(id2);

                    Console.WriteLine(foo);
                    Console.WriteLine(bar);
                }

                using (var store = new Store())
                {
                    var one = BuildMeOne();

                    store.Create(one);

                    store.SaveChanges();
                }

                using (var store = new Store())
                {
                    var readBack = store.TryRetrieve <SimplePoco>(new Guid("DA722261-062C-43DF-B64C-B17829A58440"));

                    var yo = 3334;
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }

            Console.ReadKey();
        }