在好例子网,分享、交流、成长!
您当前所在位置:首页Others 开发实例一般编程问题 → YesSql:一个在任何关系型数据库上工作的.NET文档数据库

YesSql:一个在任何关系型数据库上工作的.NET文档数据库

一般编程问题

下载此实例
  • 开发语言:Others
  • 实例大小:0.28M
  • 下载次数:0
  • 浏览次数:4
  • 发布时间:2024-05-09
  • 实例类别:一般编程问题
  • 发 布 人:chenxiaolan
  • 文件格式:.zip
  • 所需积分:2
 相关标签:

实例介绍

【实例简介】

YesSql是一个.NET Core文档数据库接口,可以在关系型数据库上定义文档和索引,使用纯粹的SQL来存储它们。与文档数据库的主要区别在于,它使用任何关系型数据库来存储文档,这为您提供了所有SQL数据库的功能,如事务、复制、报告等。但最大的优势可能是没有魔法参与,它纯粹依赖于SQL!


【实例截图】

using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Routing;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using YesSql.Filters.Query;
using YesSql.Samples.Web.ModelBinding;
using YesSql.Samples.Web.Models;
using YesSql.Samples.Web.Services;
using YesSql.Samples.Web.ViewModels;

namespace YesSql.Samples.Web.Controllers
{
    public class HomeController : Controller
    {
        private readonly IStore _store;

        public HomeController(IStore store)
        {
            _store = store;
        }

        [Route("/")]
        public async Task<IActionResult> Index([ModelBinder(BinderType = typeof(QueryFilterEngineModelBinder<BlogPost>), Name = "q")] QueryFilterResult<BlogPost> filterResult)
        {
            IEnumerable<BlogPost> posts;

            await using var session = _store.CreateSession();
            var query = session.Query<BlogPost>();

            await filterResult.ExecuteAsync(new WebQueryExecutionContext<BlogPost>(HttpContext.RequestServices, query));

            var currentSearchText = filterResult.ToString();

            posts = await query.ListAsync();

            // Map termList to model.
            // i.e. SelectedFilter needs to be filled with
            // the selected filter value from the term.
            var search = new Filter
            {
                SearchText = currentSearchText,
                OriginalSearchText = currentSearchText
            };

            filterResult.MapTo(search);

            search.Statuses = new List<SelectListItem>()
                {
                    new SelectListItem("Select...", "", search.SelectedStatus == BlogPostStatus.Default),
                    new SelectListItem("Published", BlogPostStatus.Published.ToString(), search.SelectedStatus == BlogPostStatus.Published),
                    new SelectListItem("Draft", BlogPostStatus.Draft.ToString(), search.SelectedStatus == BlogPostStatus.Draft)
                };

            search.Sorts = new List<SelectListItem>()
                {
                    new SelectListItem("Newest", BlogPostSort.Newest.ToString(), search.SelectedSort == BlogPostSort.Newest),
                    new SelectListItem("Oldest", BlogPostSort.Oldest.ToString(), search.SelectedSort == BlogPostSort.Oldest)
                };

            var vm = new BlogPostViewModel
            {
                BlogPosts = posts,
                Search = search
            };

            return View(vm);
        }

        [HttpPost("/")]
        public IActionResult IndexPost(Filter search)
        {
            // When the user has typed something into the search input no evaluation is required.
            // But we might normalize it for them.
            if (!string.Equals(search.SearchText, search.OriginalSearchText, StringComparison.OrdinalIgnoreCase))
            {
                return RedirectToAction("Index", new RouteValueDictionary { { "q", search.SearchText } });
            }

            search.FilterResult.MapFrom(search);

            return RedirectToAction("Index", new RouteValueDictionary { { "q", search.FilterResult.ToString() } });
        }
    }
}

【核心代码】
文件清单
└── yessql-7f4ab36c88d0259f188a40f6a66faca50257b1ee
    ├── LICENSE.txt
    ├── NuGet.config
    ├── README.md
    ├── samples
    │   ├── YesSql.Bench
    │   │   ├── Program.cs
    │   │   ├── Properties
    │   │   │   └── AssemblyInfo.cs
    │   │   └── YesSql.Bench.csproj
    │   ├── YesSql.Samples.FullText
    │   │   ├── Indexes
    │   │   │   ├── ArticleByWord.cs
    │   │   │   └── ArticleIndexProvider.cs
    │   │   ├── Models
    │   │   │   └── Article.cs
    │   │   ├── Program.cs
    │   │   ├── Properties
    │   │   │   └── AssemblyInfo.cs
    │   │   ├── Tokenizers
    │   │   │   ├── ITokenFilter.cs
    │   │   │   ├── ITokenizer.cs
    │   │   │   ├── StopWordFilter.cs
    │   │   │   └── WhiteSpaceTokenizer.cs
    │   │   └── YesSql.Samples.FullText.csproj
    │   ├── YesSql.Samples.Hi
    │   │   ├── Indexes
    │   │   │   ├── BlogPostByAuthor.cs
    │   │   │   ├── BlogPostByDay.cs
    │   │   │   └── BlogPostIndexProvider.cs
    │   │   ├── Models
    │   │   │   └── BlogPost.cs
    │   │   ├── Program.cs
    │   │   ├── Properties
    │   │   │   └── AssemblyInfo.cs
    │   │   └── YesSql.Samples.Hi.csproj
    │   ├── YesSql.Samples.Performance
    │   │   ├── Benchmarks.cs
    │   │   ├── Program.cs
    │   │   ├── User.cs
    │   │   └── YesSql.Samples.Performance.csproj
    │   └── YesSql.Samples.Web
    │       ├── Controllers
    │       │   └── HomeController.cs
    │       ├── Indexes
    │       │   └── BlogPostIndexProvider.cs
    │       ├── ModelBinding
    │       │   ├── FilterEngineModelBinder.cs
    │       │   └── QueryFilterEngineModelBinder.cs
    │       ├── Models
    │       │   └── BlogPost.cs
    │       ├── Program.cs
    │       ├── Properties
    │       │   └── launchSettings.json
    │       ├── Services
    │       │   └── WebQueryExecutionContext.cs
    │       ├── ViewModels
    │       │   └── BlogPostViewModel.cs
    │       ├── Views
    │       │   ├── Home
    │       │   │   └── Index.cshtml
    │       │   └── _ViewImports.cshtml
    │       └── YesSql.Samples.Web.csproj
    ├── src
    │   ├── Directory.Build.props
    │   ├── Directory.Packages.props
    │   ├── YesSql
    │   │   └── YesSql.csproj
    │   ├── YesSql.Abstractions
    │   │   ├── Commands
    │   │   │   ├── IAddColumnCommand.cs
    │   │   │   ├── IAddIndexCommand.cs
    │   │   │   ├── IAlterColumnCommand.cs
    │   │   │   ├── IAlterTableCommand.cs
    │   │   │   ├── IColumnCommand.cs
    │   │   │   ├── ICreateColumnCommand.cs
    │   │   │   ├── ICreateForeignKeyCommand.cs
    │   │   │   ├── ICreateSchemaCommand.cs
    │   │   │   ├── ICreateTableCommand.cs
    │   │   │   ├── IDropColumnCommand.cs
    │   │   │   ├── IDropForeignKeyCommand.cs
    │   │   │   ├── IDropIndexCommand.cs
    │   │   │   ├── IDropTableCommand.cs
    │   │   │   ├── IRenameColumnCommand.cs
    │   │   │   ├── ISchemaCommand.cs
    │   │   │   ├── ITableCommand.cs
    │   │   │   └── SqlStatementCommand.cs
    │   │   ├── ConcurrencyException.cs
    │   │   ├── Document.cs
    │   │   ├── IAccessor.cs
    │   │   ├── IAccessorFactory.cs
    │   │   ├── ICollection.cs
    │   │   ├── ICommandInterpreter.cs
    │   │   ├── ICompiledQuery.cs
    │   │   ├── IConfiguration.cs
    │   │   ├── IConnectionFactory.cs
    │   │   ├── IContentSerializer.cs
    │   │   ├── IdentityColumnSize.cs
    │   │   ├── IIdGenerator.cs
    │   │   ├── Indexes
    │   │   │   ├── DescribeContext.cs
    │   │   │   ├── DescribeFor.cs
    │   │   │   ├── IDescriptor.cs
    │   │   │   ├── IIndex.cs
    │   │   │   ├── IIndexProvider.cs
    │   │   │   ├── IndexDescriptor.cs
    │   │   │   ├── IndexProvider.cs
    │   │   │   ├── MapIndex.cs
    │   │   │   └── ReduceIndex.cs
    │   │   ├── IQuery.cs
    │   │   ├── ISchemaBuilder.cs
    │   │   ├── ISession.cs
    │   │   ├── ISqlBuilder.cs
    │   │   ├── ISqlDialect.cs
    │   │   ├── ISqlFunction.cs
    │   │   ├── IStore.cs
    │   │   ├── IStringBuilder.cs
    │   │   ├── ITableNameConvention.cs
    │   │   ├── ITypeService.cs
    │   │   ├── JoinType.cs
    │   │   ├── QueryExtensions.cs
    │   │   ├── SchemaBuilderExtensions.cs
    │   │   ├── SessionExtensions.cs
    │   │   ├── SimplifiedTypeName.cs
    │   │   ├── SqlBuilderExtensions.cs
    │   │   ├── Storage
    │   │   │   ├── DocumentIdentity.cs
    │   │   │   └── IIdentityEntity.cs
    │   │   └── YesSql.Abstractions.csproj
    │   ├── YesSql.Core
    │   │   ├── Commands
    │   │   │   ├── BatchCommand.cs
    │   │   │   ├── CreateDocumentCommand.cs
    │   │   │   ├── CreateIndexCommand.cs
    │   │   │   ├── DeleteDocumentCommand.cs
    │   │   │   ├── DeleteMapIndexCommand.cs
    │   │   │   ├── DeleteReduceIndexCommand.cs
    │   │   │   ├── DocumentCommand.cs
    │   │   │   ├── IIndexCommand.cs
    │   │   │   ├── IndexCommand.cs
    │   │   │   ├── UpdateDocumentCommand.cs
    │   │   │   └── UpdateIndexCommand.cs
    │   │   ├── Configuration.cs
    │   │   ├── ConfigurationExtensions.cs
    │   │   ├── Data
    │   │   │   ├── AliasBinding.cs
    │   │   │   ├── DapperDataHandlers.cs
    │   │   │   ├── MapState.cs
    │   │   │   ├── NullableThumbprintFactory.cs
    │   │   │   ├── PropertyAccessorFactory.cs
    │   │   │   └── WorkerQueryKey.cs
    │   │   ├── DbConnectionProviderFactory.cs
    │   │   ├── GlobalSuppressions.cs
    │   │   ├── Indexes
    │   │   │   └── IdentityMap.cs
    │   │   ├── Properties
    │   │   │   └── AssemblyInfo.cs
    │   │   ├── Provider
    │   │   │   ├── BaseDialect.cs
    │   │   │   └── ServiceCollectionExtensions.cs
    │   │   ├── Serialization
    │   │   │   ├── JsonContentSerializer.cs
    │   │   │   └── PropertyInfoAccessor.cs
    │   │   ├── Services
    │   │   │   ├── DbBlockIdGenerator.cs
    │   │   │   ├── DefaultIdGenerator.cs
    │   │   │   ├── DefaultQuery.cs
    │   │   │   ├── DefaultTableNameConvention.cs
    │   │   │   ├── EnumerableExtensions.cs
    │   │   │   ├── IndexProviderRegisterExtensions.cs
    │   │   │   ├── PredicateNodes.cs
    │   │   │   └── TypeService.cs
    │   │   ├── Session.cs
    │   │   ├── SessionState.cs
    │   │   ├── Sql
    │   │   │   ├── BaseComandInterpreter.cs
    │   │   │   ├── MappingFunction.cs
    │   │   │   ├── Schema
    │   │   │   │   ├── AddColumnCommand.cs
    │   │   │   │   ├── AddIndexCommand.cs
    │   │   │   │   ├── AlterColumnCommand.cs
    │   │   │   │   ├── AlterTableCommand.cs
    │   │   │   │   ├── ColumnCommand.cs
    │   │   │   │   ├── CreateColumnCommand.cs
    │   │   │   │   ├── CreateForeignKeyCommand.cs
    │   │   │   │   ├── CreateSchemaCommand.cs
    │   │   │   │   ├── CreateTableCommand.cs
    │   │   │   │   ├── DropColumnCommand.cs
    │   │   │   │   ├── DropForeignKeyCommand.cs
    │   │   │   │   ├── DropIndexCommand.cs
    │   │   │   │   ├── DropTableCommand.cs
    │   │   │   │   ├── RenameColumnCommand .cs
    │   │   │   │   ├── SchemaCommand.cs
    │   │   │   │   ├── SqlStatementCommand.cs
    │   │   │   │   └── TableCommand.cs
    │   │   │   ├── SchemaBuilder.cs
    │   │   │   ├── SqlBuilder.cs
    │   │   │   └── TemplateFunction.cs
    │   │   ├── Store.cs
    │   │   ├── StoreFactory.cs
    │   │   ├── Utils
    │   │   │   ├── HashHelper.cs
    │   │   │   └── RentedStringBuilder.cs
    │   │   └── YesSql.Core.csproj
    │   ├── YesSql.Filters.Abstractions
    │   │   ├── Builders
    │   │   │   ├── BooleanEngineBuilder.cs
    │   │   │   ├── DefaultTermEngineBuilder.cs
    │   │   │   ├── NamedTermEngineBuilder.cs
    │   │   │   ├── OperatorBuilder.cs
    │   │   │   ├── TermEngineBuilder.cs
    │   │   │   └── UnaryEngineBuilder.cs
    │   │   ├── Nodes
    │   │   │   ├── FilterNode.cs
    │   │   │   ├── OperatorNodes.cs
    │   │   │   └── TermNodes.cs
    │   │   ├── Services
    │   │   │   ├── FilterExecutionContext.cs
    │   │   │   ├── FilterResult.cs
    │   │   │   ├── IFilterParser.cs
    │   │   │   ├── IFilterVisitor.cs
    │   │   │   └── TermOption.cs
    │   │   └── YesSql.Filters.Abstractions.csproj
    │   ├── YesSql.Filters.Query
    │   │   ├── IQueryParser.cs
    │   │   ├── QueryBooleanEngineBuilder.cs
    │   │   ├── QueryEngineBuilder.cs
    │   │   ├── QueryEngineBuilderExtensions.cs
    │   │   ├── QueryFilterResult.cs
    │   │   ├── QueryFilterResultExtensions.cs
    │   │   ├── QueryTermEngineBuilderExtensions.cs
    │   │   ├── QueryUnaryEngineBuilder.cs
    │   │   ├── Services
    │   │   │   ├── QueryExecutionContext.cs
    │   │   │   ├── QueryFilterVisitor.cs
    │   │   │   ├── QueryParseContext.cs
    │   │   │   ├── QueryParser.cs
    │   │   │   └── QueryTermOption.cs
    │   │   └── YesSql.Filters.Query.csproj
    │   ├── YesSqlKey.snk
    │   ├── YesSql.Provider.MySql
    │   │   ├── MySqlCommandInterpreter.cs
    │   │   ├── MySqlDbProviderOptionsExtensions.cs
    │   │   ├── MySqlDialect.cs
    │   │   └── YesSql.Provider.MySql.csproj
    │   ├── YesSql.Provider.PostgreSql
    │   │   ├── PostgreSqlCommandInterpreter.cs
    │   │   ├── PostgreSqlDbProviderOptionsExtensions.cs
    │   │   ├── PostgreSqlDialect.cs
    │   │   └── YesSql.Provider.PostgreSql.csproj
    │   ├── YesSql.Provider.Sqlite
    │   │   ├── GlobalSuppressions.cs
    │   │   ├── SqliteCommandInterpreter.cs
    │   │   ├── SqliteDbProviderOptionsExtensions.cs
    │   │   ├── SqliteDialect.cs
    │   │   └── YesSql.Provider.Sqlite.csproj
    │   ├── YesSql.Provider.SqlServer
    │   │   ├── SqlServerComandInterpreter.cs
    │   │   ├── SqlServerDbProviderOptionsExtensions.cs
    │   │   ├── SqlServerDialect.cs
    │   │   └── YesSql.Provider.SqlServer.csproj
    │   └── yessql.pub
    ├── test
    │   └── YesSql.Tests
    │       ├── Commands
    │       │   └── DeleteDocumentCommand.cs
    │       ├── CompiledQueries
    │       │   └── PersonByAgeCompileQuery.cs
    │       ├── ConsoleLogger.cs
    │       ├── CoreTests.cs
    │       ├── DecimalPrecisionAndScaleDataGenerator.cs
    │       ├── Filters
    │       │   └── QueryEngineTests.cs
    │       ├── GlobalSuppressions.cs
    │       ├── HashHelperTests.cs
    │       ├── Indexes
    │       │   ├── ArticleByDate.cs
    │       │   ├── ArticleByDay.cs
    │       │   ├── AttachmentByDay.cs
    │       │   ├── Binary.cs
    │       │   ├── CarIndex.cs
    │       │   ├── EmailByAttachment.cs
    │       │   ├── LongestNameByLetter.cs
    │       │   ├── PersonByAge.cs
    │       │   ├── PersonByBothNamesCol.cs
    │       │   ├── PersonByNameCol.cs
    │       │   ├── PersonByName.cs
    │       │   ├── PersonByNullableAge.cs
    │       │   ├── PersonIdentity.cs
    │       │   ├── PersonsByName.cs
    │       │   ├── PropertyIndex.cs
    │       │   ├── PublishedArticles.cs
    │       │   ├── Shapes.cs
    │       │   ├── TypesIndex.cs
    │       │   └── User.cs
    │       ├── Models
    │       │   ├── Animal.cs
    │       │   ├── Article.cs
    │       │   ├── Car.cs
    │       │   ├── Drawing.cs
    │       │   ├── Email.cs
    │       │   ├── Person.cs
    │       │   ├── Products.cs
    │       │   ├── Property.cs
    │       │   ├── TestConstants.cs
    │       │   └── Tree.cs
    │       ├── MySqlTests.cs
    │       ├── NullableThumbprint
    │       │   ├── Discriminators.cs
    │       │   └── NullableThumbprintFactoryTests.cs
    │       ├── PostgreSqlLegacyIdentityTests.cs
    │       ├── PostgreSqlTests.cs
    │       ├── Properties
    │       │   └── AssemblyInfo.cs
    │       ├── ProviderTests.cs
    │       ├── SqliteLegacyIdentityTests.cs
    │       ├── SqliteTests.cs
    │       ├── SqlServer2017Tests.cs
    │       ├── SqlServer2019Tests.cs
    │       ├── SqlServerTests.cs
    │       ├── TemporaryFolder.cs
    │       ├── TestLogger.cs
    │       ├── WorkerQueryKeyTests.cs
    │       ├── xunit.runner.json
    │       └── YesSql.Tests.csproj
    └── YesSql.sln

60 directories, 266 files

标签:

实例下载地址

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警