Commit b920638f by 施晓雨

添加项目文件。

parent b2fe79e0
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<connectionStrings>
<!--<add name="Database" providerName="Sqlite" connectionString="$ROOT\AppData\primary.sqlite"/>-->
</connectionStrings></configuration>
\ No newline at end of file
using Kivii.DataAnnotations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Kivii.Linq.Test.Entities
{
[Alias("CUST_Contacts")]
public class Contact:EntityWithMetadata
{
public Guid CustomerKvid { get; set; }
public string FullName { get; set; }
public string MobilePhone { get; set; }
}
public class ContactEx : Contact
{
public string CustomerFullName { get; set; }
public string CustomerAddress { get; set; }
}
}
using Kivii.DataAnnotations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Kivii.Linq.Test.Entities
{
[Alias("CUST_Customers")]
public class Customer:Entity
{
public string FullName { get; set; }
public string Address { get; set; }
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{583942E0-D732-443F-9B6F-9039FC72EBBA}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Kivii.Linq.Test</RootNamespace>
<AssemblyName>Kivii.Linq.Test</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Kivii.Common.V4.5, Version=5.4.2019.6200, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Kivii.Common.5.4.2019.6200\lib\net45\Kivii.Common.V4.5.dll</HintPath>
</Reference>
<Reference Include="Kivii.Linq.Sqlite.V4.5, Version=5.4.2019.6200, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Kivii.Linq.Sqlite.5.4.2019.6200\lib\net45\Kivii.Linq.Sqlite.V4.5.dll</HintPath>
</Reference>
<Reference Include="Kivii.Linq.V4.5, Version=5.4.2019.6200, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Kivii.Linq.5.4.2019.6200\lib\net45\Kivii.Linq.V4.5.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Entities\Contact.cs" />
<Compile Include="Entities\Customer.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Samples\JoinTest.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.329
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kivii.Linq.Test.V4.5", "Kivii.Linq.Test.V4.5.csproj", "{583942E0-D732-443F-9B6F-9039FC72EBBA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{583942E0-D732-443F-9B6F-9039FC72EBBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{583942E0-D732-443F-9B6F-9039FC72EBBA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{583942E0-D732-443F-9B6F-9039FC72EBBA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{583942E0-D732-443F-9B6F-9039FC72EBBA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {10ADB988-663F-48FE-AA22-BC385C85057C}
EndGlobalSection
EndGlobal
using Kivii.Linq.Test.Samples;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Kivii.Linq.Test
{
class Program
{
static void Main(string[] args)
{
var localDbPath = KiviiContext.Combine(KiviiContext.BaseDirectoryString, KiviiContext.AppDataFolder, $"test.sqlite");
var localFactory = Kivii.Linq.LinqUtils.GetLinqConnectionFactory(localDbPath, "Sqlite");
var conn = localFactory.OpenDbConnection();
var joinTest = new JoinTest();
joinTest.Connection = conn;
joinTest.JoinTwoEntities();
conn.Dispose();
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Kivii.Linq.Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Kivii.Linq.Test")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("583942e0-d732-443f-9b6f-9039fc72ebba")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
using Kivii.Linq.Test.Entities;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Kivii.Linq.Test.Samples
{
public class JoinTest
{
public IDbConnection Connection { get; set; }
public void JoinTwoEntities()
{
Connection.InitEntityType<Customer>();
Connection.InitEntityType<Contact>();
Connection.Delete<Customer>(o => o.Status > 0);
Connection.Delete<Contact>(o => o.Status > 0);
var newCustomer = new Customer();
newCustomer.FullName = "南京凯佩软件有限公司";
newCustomer.Address = "南京万达茂";
Connection.Insert(newCustomer);
var newContact = new Contact();
newContact.FullName = "施晓雨";
newContact.MobilePhone = "13951678284";
newContact.CustomerKvid = newCustomer.Kvid;
Connection.Insert(newContact);
newContact = new Contact();
newContact.FullName = "任天宇";
newContact.MobilePhone = "139000000";
newContact.CustomerKvid = newCustomer.Kvid;
Connection.Insert(newContact);
var query = Connection.From<Contact>()
.LeftJoin<Customer>((contact, customer) => contact.CustomerKvid == customer.Kvid)
.Select<Contact, Customer>((contact, customer) => new { T=Sql.AllFields(contact), CustomerFullName = customer.FullName,CustomerAddress=customer.Address })
.Where<Contact>(contact=>contact.FullName.Contains("施"))//在两个不同表中组合查询条件
.And<Customer>(customer=>customer.FullName.Contains("南京"));//在两个不同表中组合查询条件
var rtns = Connection.Select<ContactEx>(query);
var myContact = rtns[0];
Console.WriteLine(Connection.GetLastSql());
Console.WriteLine($"CustomerFullName:{myContact.CustomerFullName},FullName:{myContact.FullName},MobilePhone:{myContact.MobilePhone}");
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Kivii.Common" version="5.4.2019.6200" targetFramework="net45" />
<package id="Kivii.Linq" version="5.4.2019.6200" targetFramework="net45" />
<package id="Kivii.Linq.Sqlite" version="5.4.2019.6200" targetFramework="net45" />
</packages>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment