NHibernateOscar 1.0.1

dotnet add package NHibernateOscar --version 1.0.1
NuGet\Install-Package NHibernateOscar -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NHibernateOscar" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NHibernateOscar --version 1.0.1
#r "nuget: NHibernateOscar, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install NHibernateOscar as a Cake Addin
#addin nuget:?package=NHibernateOscar&version=1.0.1

// Install NHibernateOscar as a Cake Tool
#tool nuget:?package=NHibernateOscar&version=1.0.1

快速开始

配置文件 nhibernate.cfg.xml

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
  <session-factory>
    <property name="connection.driver_class">
      NHibernate.Driver.OscarDriver,OscarNHibernate
    </property>
    <property name="connection.connection_string">
      Server=127.0.0.1;Port=2003;User Id=SYSDBA;Password=szoscar55;Database=OSRDB
    </property>
    <property name="adonet.batch_size">10 </property>
    <property name="show_sql">true</property>
    <property name="dialect">
      NHibernate.Dialect.OscarDialect,OscarNHibernate
    </property>
    <property name="command_timeout">10</property>
    <property name="query.substitutions">
      true 1, false 0,yes 'Y', no 'N'
    </property>
    <mapping assembly="DomainModel"/>
  </session-factory>
</hibernate-configuration>

注意: 确保配置文件发布被编译到项目发布包中 请确保 .csproj 配置中有一下内容

<ItemGroup>
    <None Remove="nhibernate.cfg.xml" />
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Include="nhibernate.cfg.xml">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </EmbeddedResource>
  </ItemGroup>

使用用例

using DomainModel.Domain;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NHibernate;
using NHibernate.Cfg;
using System;
using System.Data.OscarClient;
using System.Linq;

namespace NETStandardTest
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod()
        {
            try
            {
                Configuration cfg = new Configuration();
                cfg.Configure("nhibernate.cfg.xml");

                using ISessionFactory factory = cfg.BuildSessionFactory();
                using var session = factory.OpenSession();
                ITransaction trans = session.BeginTransaction();
                var np = new Product();
                np.Id = 18;
                np.Name = "zeng";

                session.Save(np);
                trans.Commit();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }

        [TestMethod]
        public void TestSkipTakeMethod()
        {
            try
            {
                Configuration cfg = new Configuration();
                cfg.Configure("nhibernate.cfg.xml");

                using ISessionFactory factory = cfg.BuildSessionFactory();
                using var session = factory.OpenSession();
                var list = session.Query<Product>().Where(u => u.Name == "zeng").Skip(1).Take(1).ToList();
                list = session.Query<Product>().Where(u => u.Name == "zeng").Skip(0).Take(2).ToList();
                list = session.Query<Product>().Where(u => u.Name == "zeng").Skip(1).Take(3).ToList();
                list = session.Query<Product>().Where(u => u.Name == "zeng").Take(3).ToList();
                list = session.Query<Product>().Where(u => u.Name == "zeng").Skip(1).ToList();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
    }
}
Product Compatible and additional computed target framework versions.
.NET Framework net35 is compatible.  net40 was computed.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 481 11/9/2020