コード例 #1
0
        public HttpResponseMessage PostComplex(UpdateExamples update)
        {
            if (ModelState.IsValid && update != null)
            {
                // Convert any HTML markup in the status text.
                update.Status = HttpUtility.HtmlEncode(update.Status);

                // Assign a new ID.
                var id = Guid.NewGuid();
                updates[id] = update;

                // Create a 201 response.
                var response = new HttpResponseMessage(HttpStatusCode.Created)
                {
                    Content = new StringContent(update.Status)
                };
                response.Headers.Location =
                    new Uri(Url.Link("DefaultApi", new { action = "status", id = id + "asasasas" }));
                return(response);
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
コード例 #2
0
        public static void RunExamples(string connectionString)
        {
            ConnectionExample.UseSharedConnection(connectionString);

            NameConventionResolutionExample.CheckDifferentNamesForSameTable(connectionString);
            //NameConventionResolutionExample.ThrowOnPotentialTableNamesConflict(connectionString);

            SimpleRecordExamples.GetByPrimaryKey(connectionString);
            SimpleRecordExamples.FindByGenreId(connectionString);
            SimpleRecordExamples.FindByGenreIdAndYear(connectionString);
            SimpleRecordExamples.FindByGenreIdOrYear(connectionString);


            SimpleQueryExamples.GetAllOfThem(connectionString);

            SimpleQueryExamples.FindAllOfThem(connectionString);
            SimpleQueryExamples.FindAllOfThemWithAnd(connectionString);
            SimpleQueryExamples.FindAllOfThemWithOr(connectionString);

            SimpleQueryExamples.FindAllOfThemBy(connectionString);
            SimpleQueryExamples.FindAllOfThemByNamedParameterVersion(connectionString);
            SimpleQueryExamples.FindAllOfThemByWithAnd(connectionString);
            SimpleQueryExamples.FindAllOfThemByWithAndNamedParameterVersion(connectionString);


            QueryModifiersExamples.SelectSomething(connectionString);
            QueryModifiersExamples.SelectSomethingWithAlias(connectionString);
            QueryModifiersExamples.SelectSomethingWithDistinct(connectionString);
            QueryModifiersExamples.SelectSomethingWithWhere(connectionString);
            QueryModifiersExamples.SelectSomethingWithCombinedWhere(connectionString);

            QueryModifiersExamples.WhereWithIn(connectionString);
            QueryModifiersExamples.WhereWithBetween(connectionString);
            QueryModifiersExamples.WhereWithLike(connectionString);


            ScalarQueriesExample.GetCountByColumn(connectionString);
            ScalarQueriesExample.GetCountByColumnFluent(connectionString);
            ScalarQueriesExample.CheckExistsByColumn(connectionString);
            ScalarQueriesExample.CheckExistsByColumnFluent(connectionString);


            OrderingExamples.OrderBy(connectionString);
            OrderingExamples.OrderByDescending(connectionString);
            OrderingExamples.OrderByInJoinedTablesByPrimaryTable(connectionString);
            OrderingExamples.OrderByInJoinedTablesByJoinedTable(connectionString);
            OrderingExamples.ThenBy(connectionString);
            OrderingExamples.ThenByDescending(connectionString);


            ExplicitJoinExamples.SimpleJoin(connectionString);
            ExplicitJoinExamples.SimpleJoinWithOn(connectionString);
            ExplicitJoinExamples.SimpleJoinWithAlias(connectionString);
            ExplicitJoinExamples.MoreComplexJoin(connectionString);
            ExplicitJoinExamples.MoreComplexJoinWithFilter(connectionString);

            NaturalJoinExamples.SimpleJoin(connectionString);
            NaturalJoinExamples.MoreComplexJoin(connectionString);
            NaturalJoinExamples.MoreComplexJoinWithFilter(connectionString);


            AggragateFunctionsExample.AggregateWithCount(connectionString);
            AggragateFunctionsExample.AggregateWithCount2(connectionString);
            AggragateFunctionsExample.SimpleHaving(connectionString);
            AggragateFunctionsExample.AggregateWithCountAndFilter(connectionString);
            AggragateFunctionsExample.AggregateWithCountAndOrFilter(connectionString);
            AggragateFunctionsExample.AggregateWithCountAndSumFilter(connectionString);
            AggragateFunctionsExample.AggregateWithCountAndMinFilter(connectionString);

            LazyAndEagerLoadingExample.SimpleLazyLoading(connectionString);
            LazyAndEagerLoadingExample.SimpleEagerLoading(connectionString);
            LazyAndEagerLoadingExample.NaiveEagerLoading(connectionString);
            LazyAndEagerLoadingExample.SimpleEagerLoading(connectionString);
            LazyAndEagerLoadingExample.ComplexEagerLoading(connectionString);
            LazyAndEagerLoadingExample.ComplexEagerLoadingShorterWith(connectionString);
            LazyAndEagerLoadingExample.ComplexEagerLoadingShorterWithAndFilter(connectionString);
            LazyAndEagerLoadingExample.ComplexEagerLoadingShorterWithAndFilterAndSingleActor(connectionString);
            LazyAndEagerLoadingExample.ComplexEagerLoadingNonForeignKeyRelationship(connectionString);

            CastingToObjectsExample.SimpleRecordImplicitCast(connectionString);
            CastingToObjectsExample.SimpleRecordImplicitCastWhenNoRecords(connectionString);
            CastingToObjectsExample.SimpleRecordImplicitCastWhenCastingToWrongType(connectionString);
            CastingToObjectsExample.SimpleRecordImplicitCastWhenCastingToAlmostWrongType(connectionString);

            CastingToObjectsExample.SimpleQueryImplicitCast(connectionString);
            CastingToObjectsExample.SimpleQueryImplicitCastWhenNoRecords(connectionString);
            CastingToObjectsExample.SimpleQueryImplicitCastWhenCastingToWrongType(connectionString);
            CastingToObjectsExample.SimpleQueryImplicitCastWhenCastingToAlmostWrongType(connectionString);
            //CastingToObjectsExample.ThrowOnSimpleQueryAndRecordImplicitCastMismatch(connectionString);

            CastingToScalarExample.SimpleRecordImplicitCastToScalar(connectionString);
            CastingToScalarExample.SimpleQueryImplicitCastToScalar(connectionString);
            CastingToScalarExample.SimpleQueryImplicitCastToScalarList(connectionString);

            PagingFunctionExample.SkipFirstTwoAndTakeTwoNext(connectionString);
            PagingFunctionExample.SinglePageWithTotalCount(connectionString);
            PagingFunctionExample.MultiPageWithTotalCount(connectionString);

            InsertExamples.InsertByNamedParameters(connectionString);
            InsertExamples.InsertByObject(connectionString);
            InsertExamples.MultiInsert(connectionString);

            UpdateExamples.UpdateByObject(connectionString);
            UpdateExamples.UpdateByNamedParametersWhenNoPrimaryKey(connectionString);
            UpdateExamples.UpdateByWhenNoPrimaryKey(connectionString);
            UpdateExamples.UpdateAllWithCriteria(connectionString);

            DeleteExamples.DeleteByNamedParameter(connectionString);
            DeleteExamples.DeleteBy(connectionString);
            DeleteExamples.DeleteAllWithCriteria(connectionString);

            TransactionExamples.RunTransactionWithRolback(connectionString);
            TransactionExamples.RunTransactionWithCommit(connectionString);
        }