Esempio n. 1
0
        public static void SimpleDbRecordWithOptionsAndMultipleColumnsAndFilter()
        {
            IEnumerable <IDictionary <string, object> > table;

            using (var connection =
                       new SqlConnection("Data Source=localhost;Initial Catalog=DatingApp;Integrated Security=True"))
            {
                connection.Open();
                const string data = @"
SELECT * from test
";
                table = connection.Query(data) as IEnumerable <IDictionary <string, object> >;
            }

            var enumerable = table as IDictionary <string, object>[] ??
                             (table ?? throw new InvalidOperationException()).ToArray();
            var s = DbTable.Add(enumerable, new Options
            {
                DateFormat    = "dd-MM-yy",
                DecimalFormat = "#,##0.########"
            }).FilterColumns(new[] { "AssetClass" }, FilterAction.Exclude).ToString();

            Console.WriteLine(s);

            s = DbTable.Add(enumerable, new Options
            {
                DateFormat    = "dd-MM-yy",
                DecimalFormat = "#,##0.########"
            }).FilterColumns(new[] { "AssetClass" }, FilterAction.Exclude).ToSpecFlowString();
            Console.WriteLine(s);
        }
Esempio n. 2
0
        public static void SimpleDbRecord()
        {
            IEnumerable <IDictionary <string, object> > table;

            using (var connection =
                       new SqlConnection("Data Source=localhost;Initial Catalog=DatingApp;Integrated Security=True"))
            {
                connection.Open();
                const string data = @"
SELECT [Id]
      ,[SenderId]
      ,[SenderUsername]
      ,[RecipientId]
      ,[RecipientUsername]
      ,[Content]
      ,[DateRead]
      ,[MessageSent]
      ,[SenderDeleted]
      ,[RecipientDeleted]
  FROM [DatingApp].[dbo].[Messages]
";
                table = connection.Query(data) as IEnumerable <IDictionary <string, object> >;
            }

            var enumerable = table as IDictionary <string, object>[] ??
                             (table ?? throw new InvalidOperationException()).ToArray();
            var s = DbTable.Add(enumerable).ToString();

            Console.WriteLine(s);

            s = DbTable.Add(enumerable).ToSpecFlowString();
            Console.WriteLine(s);
        }
Esempio n. 3
0
        public new async Task <int> CreateAsync(User user)
        {
            DbTable.Add(user);

            var result = await SaveChangesAsync();

            _usersCache.Invalidate((await ReadAllAsync()).ToList());

            return(result);
        }