Jelajahi Sumber

条件编译

懒得勤快 6 tahun lalu
induk
melakukan
7632ea0465

+ 2 - 0
Masuit.LuceneEFCore.SearchEngine.Test/Masuit.LuceneEFCore.SearchEngine.Test.csproj

@@ -4,6 +4,8 @@
     <TargetFramework>netcoreapp2.2</TargetFramework>
 
     <IsPackable>false</IsPackable>
+
+    <Configurations>Debug;Release;String版本;Guid版本;Long版本</Configurations>
   </PropertyGroup>
 
   <ItemGroup>

+ 22 - 1
Masuit.LuceneEFCore.SearchEngine.sln

@@ -7,26 +7,47 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Masuit.LuceneEFCore.SearchE
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Masuit.LuceneEFCore.SearchEngine.Test", "Masuit.LuceneEFCore.SearchEngine.Test\Masuit.LuceneEFCore.SearchEngine.Test.csproj", "{0E1A15E2-174C-4FE3-A4CC-A77B9BC326E8}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebSearchDemo", "WebSearchDemo\WebSearchDemo.csproj", "{12EF81D1-26CF-417C-A814-BB49A0F87AFE}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebSearchDemo", "WebSearchDemo\WebSearchDemo.csproj", "{12EF81D1-26CF-417C-A814-BB49A0F87AFE}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
+		Guid版本|Any CPU = Guid版本|Any CPU
+		Long版本|Any CPU = Long版本|Any CPU
 		Release|Any CPU = Release|Any CPU
+		String版本|Any CPU = String版本|Any CPU
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
 		{1A9A907B-8254-40EF-BB80-47B716919B07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{1A9A907B-8254-40EF-BB80-47B716919B07}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{1A9A907B-8254-40EF-BB80-47B716919B07}.Guid版本|Any CPU.ActiveCfg = Guid版本|Any CPU
+		{1A9A907B-8254-40EF-BB80-47B716919B07}.Guid版本|Any CPU.Build.0 = Guid版本|Any CPU
+		{1A9A907B-8254-40EF-BB80-47B716919B07}.Long版本|Any CPU.ActiveCfg = Long版本|Any CPU
+		{1A9A907B-8254-40EF-BB80-47B716919B07}.Long版本|Any CPU.Build.0 = Long版本|Any CPU
 		{1A9A907B-8254-40EF-BB80-47B716919B07}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{1A9A907B-8254-40EF-BB80-47B716919B07}.Release|Any CPU.Build.0 = Release|Any CPU
+		{1A9A907B-8254-40EF-BB80-47B716919B07}.String版本|Any CPU.ActiveCfg = String版本|Any CPU
+		{1A9A907B-8254-40EF-BB80-47B716919B07}.String版本|Any CPU.Build.0 = String版本|Any CPU
 		{0E1A15E2-174C-4FE3-A4CC-A77B9BC326E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{0E1A15E2-174C-4FE3-A4CC-A77B9BC326E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{0E1A15E2-174C-4FE3-A4CC-A77B9BC326E8}.Guid版本|Any CPU.ActiveCfg = Guid版本|Any CPU
+		{0E1A15E2-174C-4FE3-A4CC-A77B9BC326E8}.Guid版本|Any CPU.Build.0 = Guid版本|Any CPU
+		{0E1A15E2-174C-4FE3-A4CC-A77B9BC326E8}.Long版本|Any CPU.ActiveCfg = Long版本|Any CPU
+		{0E1A15E2-174C-4FE3-A4CC-A77B9BC326E8}.Long版本|Any CPU.Build.0 = Long版本|Any CPU
 		{0E1A15E2-174C-4FE3-A4CC-A77B9BC326E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{0E1A15E2-174C-4FE3-A4CC-A77B9BC326E8}.Release|Any CPU.Build.0 = Release|Any CPU
+		{0E1A15E2-174C-4FE3-A4CC-A77B9BC326E8}.String版本|Any CPU.ActiveCfg = String版本|Any CPU
+		{0E1A15E2-174C-4FE3-A4CC-A77B9BC326E8}.String版本|Any CPU.Build.0 = String版本|Any CPU
 		{12EF81D1-26CF-417C-A814-BB49A0F87AFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{12EF81D1-26CF-417C-A814-BB49A0F87AFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{12EF81D1-26CF-417C-A814-BB49A0F87AFE}.Guid版本|Any CPU.ActiveCfg = Guid版本|Any CPU
+		{12EF81D1-26CF-417C-A814-BB49A0F87AFE}.Guid版本|Any CPU.Build.0 = Guid版本|Any CPU
+		{12EF81D1-26CF-417C-A814-BB49A0F87AFE}.Long版本|Any CPU.ActiveCfg = Long版本|Any CPU
+		{12EF81D1-26CF-417C-A814-BB49A0F87AFE}.Long版本|Any CPU.Build.0 = Long版本|Any CPU
 		{12EF81D1-26CF-417C-A814-BB49A0F87AFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{12EF81D1-26CF-417C-A814-BB49A0F87AFE}.Release|Any CPU.Build.0 = Release|Any CPU
+		{12EF81D1-26CF-417C-A814-BB49A0F87AFE}.String版本|Any CPU.ActiveCfg = String版本|Any CPU
+		{12EF81D1-26CF-417C-A814-BB49A0F87AFE}.String版本|Any CPU.Build.0 = String版本|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 15 - 1
Masuit.LuceneEFCore.SearchEngine/Interfaces/ILuceneIndexable.cs

@@ -1,4 +1,7 @@
-using Lucene.Net.Documents;
+#if Guid
+using System; 
+#endif
+using Lucene.Net.Documents;
 
 namespace Masuit.LuceneEFCore.SearchEngine.Interfaces
 {
@@ -10,7 +13,18 @@ namespace Masuit.LuceneEFCore.SearchEngine.Interfaces
         /// <summary>
         /// 主键id
         /// </summary>
+#if Int
         int Id { get; set; }
+#endif
+#if Long
+        long Id { get; set; } 
+#endif
+#if String
+        string Id { get; set; } 
+#endif
+#if Guid
+        Guid Id { get; set; } 
+#endif
 
         /// <summary>
         /// 索引id

+ 11 - 0
Masuit.LuceneEFCore.SearchEngine/LuceneIndexableBaseEntity.cs

@@ -18,7 +18,18 @@ namespace Masuit.LuceneEFCore.SearchEngine
         /// 主键id
         /// </summary>
         [LuceneIndex(Name = "Id", Store = Field.Store.YES, Index = Field.Index.NOT_ANALYZED), Key]
+#if Int
         public int Id { get; set; }
+#endif
+#if Long
+        public long Id { get; set; } 
+#endif
+#if String
+        public string Id { get; set; } 
+#endif
+#if Guid
+        public Guid Id { get; set; } 
+#endif
 
         /// <summary>
         /// 索引唯一id

+ 24 - 0
Masuit.LuceneEFCore.SearchEngine/Masuit.LuceneEFCore.SearchEngine.csproj

@@ -11,6 +11,30 @@
     <PackageProjectUrl>https://github.com/ldqk/Masuit.LuceneEFCore.SearchEngine</PackageProjectUrl>
     <PackageId>Masuit.LuceneEFCore.SearchEngine_int</PackageId>
     <Version>1.0.1.1</Version>
+    <Configurations>Debug;Release;String版本;Guid版本;Long版本</Configurations>
+  </PropertyGroup>
+
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
+    <DefineConstants>TRACE;Int</DefineConstants>
+  </PropertyGroup>
+
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
+    <DefineConstants>TRACE;Int</DefineConstants>
+  </PropertyGroup>
+
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Long版本|AnyCPU'">
+    <DefineConstants>TRACE;Long</DefineConstants>
+    <Optimize>true</Optimize>
+  </PropertyGroup>
+
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Guid版本|AnyCPU'">
+    <DefineConstants>TRACE;Guid</DefineConstants>
+    <Optimize>true</Optimize>
+  </PropertyGroup>
+
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='String版本|AnyCPU'">
+    <DefineConstants>TRACE;String</DefineConstants>
+    <Optimize>true</Optimize>
   </PropertyGroup>
   <ItemGroup>
     <PackageReference Include="JieBa.Lucene.Analyzer" Version="1.0.1" />

+ 1 - 0
WebSearchDemo/WebSearchDemo.csproj

@@ -3,6 +3,7 @@
   <PropertyGroup>
     <TargetFramework>netcoreapp2.2</TargetFramework>
     <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
+    <Configurations>Debug;Release;String版本;Guid版本;Long版本</Configurations>
   </PropertyGroup>
 
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">