Пример #1
0
        public void Generic_DbRawSqlQuery_ToString_returns_the_query_but_not_the_parameters()
        {
            var query =
                new DbRawSqlQuery <FakeEntity>(
                    MockHelper.CreateInternalSqlSetQuery("select * from Products where Id < {0} and CategoryId = '{1}'", 4, "Beverages"));

            Assert.Equal("select * from Products where Id < {0} and CategoryId = '{1}'", query.ToString());
        }
Пример #2
0
        public void Non_entity_SQL_query_GetList_throws_indicating_that_binding_to_queries_is_not_allowed()
        {
            var query = new DbRawSqlQuery <Random>(MockHelper.CreateInternalSqlNonSetQuery("query"));

            Assert.Equal(
                Strings.DbQuery_BindingToDbQueryNotSupported,
                Assert.Throws <NotSupportedException>(() => ((IListSource)query).GetList()).Message);
        }
Пример #3
0
        public void Generic_DbSqlQuery_ToString_returns_the_query_but_not_the_parameters()
        {
            var query =
                new DbRawSqlQuery<FakeEntity>(
                    MockHelper.CreateInternalSqlSetQuery("select * from Products where Id < {0} and CategoryId = '{1}'", 4, "Beverages"));

            Assert.Equal("select * from Products where Id < {0} and CategoryId = '{1}'", query.ToString());
        }
Пример #4
0
            public void MaxAsync_throws_OperationCanceledException_if_task_is_cancelled()
            {
                var query = new DbRawSqlQuery <FakeEntity>(MockHelper.CreateInternalSqlNonSetQuery("select * from products"));

                Assert.Throws <OperationCanceledException>(
                    () => query.MaxAsync(new CancellationToken(canceled: true))
                    .GetAwaiter().GetResult());
            }
Пример #5
0
            public void Non_generic_ToListAsync_throws_OperationCanceledException_if_task_is_cancelled()
            {
                var query = new DbRawSqlQuery(MockHelper.CreateInternalSqlSetQuery("query", false, 1, 2));

                Assert.Throws <OperationCanceledException>(
                    () => query.ToListAsync(new CancellationToken(canceled: true))
                    .GetAwaiter().GetResult());
            }
Пример #6
0
            public void ToDictionaryAsync_throws_OperationCanceledException_if_task_is_cancelled()
            {
                var query = new DbRawSqlQuery <FakeEntity>(MockHelper.CreateInternalSqlNonSetQuery("select * from products"));

                Assert.Throws <OperationCanceledException>(
                    () => query.ToDictionaryAsync(n => n, new CancellationToken(canceled: true))
                    .GetAwaiter().GetResult());

                Assert.Throws <OperationCanceledException>(
                    () => query.ToDictionaryAsync(n => n, n => n, new CancellationToken(canceled: true))
                    .GetAwaiter().GetResult());

                var equalityComparer = new Mock <IEqualityComparer <FakeEntity> >().Object;

                Assert.Throws <OperationCanceledException>(
                    () => query.ToDictionaryAsync(n => n, equalityComparer, new CancellationToken(canceled: true))
                    .GetAwaiter().GetResult());

                Assert.Throws <OperationCanceledException>(
                    () => query.ToDictionaryAsync(n => n, n => n, equalityComparer, new CancellationToken(canceled: true))
                    .GetAwaiter().GetResult());
            }
Пример #7
0
        public ActionResult Login(string userName, string password)
        {
            // var query = (from Users in db.UsersContext  where dbUsers.kullaniciAdi==userName select dbUsers.kullaniciSifresi);

            try {

                data1 = db.UsersContext.SqlQuery("select * from Users where kullaniciSifresi=@p0", password);

                // data1 = db.Database.SqlQuery<Users>("select * from Users where kullaniciSifresi=@p0", password);
                foreach (var custinfo in data1)
                {
                    a = custinfo.kullaniciAdi.ToString();
                    b = custinfo.kullaniciSifresi.ToString();

                }

                //var User = from m in db.UsersContext select m;
                //User = User.Where(s => s.kullaniciSifresi.Contains(password));

                //foreach (var custinfo in User)
                //{
                //    a = custinfo.kullaniciAdi.ToString();
                //    b = custinfo.kullaniciSifresi.ToString();

                //}

            }
            catch(Exception x) {
                x.Message.ToString();
            }

            try {

                if (a.Equals(userName) && b.Equals(password))
                {
                    Session["user"] = new Users() { kullaniciAdi = Convert.ToInt32(a), kullaniciSifresi = b };
                    return RedirectToAction("Index");
                }
            }
            catch { }

            return View();
        }
Пример #8
0
        public void DbRawSqlQuery_ContainsListCollection_returns_false()
        {
            var query = new DbRawSqlQuery <FakeEntity>(MockHelper.CreateInternalSqlSetQuery("query"));

            Assert.False(((IListSource)query).ContainsListCollection);
        }
Пример #9
0
        public void Generic_DbRawSqlQuery_ToString_returns_the_query()
        {
            var query = new DbRawSqlQuery <FakeEntity>(MockHelper.CreateInternalSqlSetQuery("select * from products"));

            Assert.Equal("select * from products", query.ToString());
        }
Пример #10
0
        public void DbSqlQuery_ContainsListCollection_returns_false()
        {
            var query = new DbRawSqlQuery<FakeEntity>(MockHelper.CreateInternalSqlSetQuery("query"));

            Assert.False(((IListSource)query).ContainsListCollection);
        }
Пример #11
0
        public void Non_entity_SQL_query_GetList_throws_indicating_that_binding_to_queries_is_not_allowed()
        {
            var query = new DbRawSqlQuery<Random>(MockHelper.CreateInternalSqlNonSetQuery("query"));

            Assert.Equal(
                Strings.DbQuery_BindingToDbQueryNotSupported,
                Assert.Throws<NotSupportedException>(() => ((IListSource)query).GetList()).Message);
        }
Пример #12
0
        public void Generic_DbSqlQuery_ToString_returns_the_query()
        {
            var query = new DbRawSqlQuery<FakeEntity>(MockHelper.CreateInternalSqlSetQuery("select * from products"));

            Assert.Equal("select * from products", query.ToString());
        }
Пример #13
0
            public void Non_generic_DbSqlQuery_AsStreaming_returns_new_object_with_streaming_flag_set()
            {
                var query = new DbRawSqlQuery(MockHelper.CreateInternalSqlSetQuery("query", false, 1, 2));

                DynamicAsStreamingTest(query);
            }