Commit 62332030 authored by tr's avatar tr

1、表格常用处理

parent 21b88372
################################################################################
# 此 .gitignore 文件已由 Microsoft(R) Visual Studio 自动创建。
################################################################################
/FunnyPick/.vs/FunnyPick/v16/Server/sqlite3
/FunnyPick/.vs/FunnyPick/v16/.suo
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}
\ No newline at end of file
File added

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29411.108
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FunnyPick", "FunnyPick\FunnyPick.csproj", "{74FE44AE-D01E-41FC-9DD1-65A5DA2CFC7B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{74FE44AE-D01E-41FC-9DD1-65A5DA2CFC7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{74FE44AE-D01E-41FC-9DD1-65A5DA2CFC7B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74FE44AE-D01E-41FC-9DD1-65A5DA2CFC7B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74FE44AE-D01E-41FC-9DD1-65A5DA2CFC7B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A677CBE6-FA1C-41E0-9F04-546808BA8B2D}
EndGlobalSection
EndGlobal
using System;
using System.Data;
using System.Linq;
namespace FunnyPick
{
/// <summary>
/// Author : tr
/// <para>For reference only</para>
/// </summary>
public class EasyDataTable
{
//1. When you need a dictionary
public void Example1()
{
//a temporary table
DataTable dt = new DataTable()
{
TableName = "Example",
Columns = {
{ "Name", typeof(string)},
{ "Value", typeof(string)},
},
Rows = {
{ "FtpUrl", "ftp://192.168.1.2:21" },
{ "HttpUrl", "http://192.168.1.2:8000/ftproot/erp" },
}
};
//turn it into a dictionary
var dic = dt.Rows.Cast<DataRow>().ToDictionary(x => x[0].ToString(), x => x[1].ToString());
//result : {}
}
//2. When you need a string
public void Example2()
{
//a temporary table
DataTable dt = new DataTable()
{
TableName = "Example",
Columns = {
{ "ID", typeof(int)},
{ "Name", typeof(string)},
},
Rows = {
{ 1, "name1" },
{ 2, "name2" },
{ 3, "name3" },
{ 4, "name2" },
{ 5, "name2" },
}
};
//convert to string
var list = dt.Select().AsEnumerable().Select(x => x["Name"].ToString()).Distinct();
var str = string.Join(",", list);
// result : "name1,name2,name3"
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
</Project>
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("FunnyPick")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("FunnyPick")]
[assembly: System.Reflection.AssemblyTitleAttribute("FunnyPick")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// 由 MSBuild WriteCodeFragment 类生成。
{
"version": 1,
"dgSpecHash": "fw80HZqvm5AVgRwJbMlF6y3GYKRDQ1jrGvQ1sh3sZbiI99GtL6KoEjTsP3CBjWXIjs3fgrgf8hRx5j+6D1vZjA==",
"success": true
}
\ No newline at end of file
{
"format": 1,
"restore": {
"D:\\source\\Ftt_Common\\FunnyPick\\FunnyPick\\FunnyPick.csproj": {}
},
"projects": {
"D:\\source\\Ftt_Common\\FunnyPick\\FunnyPick\\FunnyPick.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "D:\\source\\Ftt_Common\\FunnyPick\\FunnyPick\\FunnyPick.csproj",
"projectName": "FunnyPick",
"projectPath": "D:\\source\\Ftt_Common\\FunnyPick\\FunnyPick\\FunnyPick.csproj",
"packagesPath": "C:\\Users\\Feteto\\.nuget\\packages\\",
"outputPath": "D:\\source\\Ftt_Common\\FunnyPick\\FunnyPick\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
],
"configFilePaths": [
"C:\\Users\\Feteto\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"netcoreapp3.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.0": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.0": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.0.100\\RuntimeIdentifierGraph.json"
}
}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Feteto\.nuget\packages\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.3.0</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ No newline at end of file
{
"version": 3,
"targets": {
".NETCoreApp,Version=v3.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
".NETCoreApp,Version=v3.0": []
},
"packageFolders": {
"C:\\Users\\Feteto\\.nuget\\packages\\": {},
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "D:\\source\\Ftt_Common\\FunnyPick\\FunnyPick\\FunnyPick.csproj",
"projectName": "FunnyPick",
"projectPath": "D:\\source\\Ftt_Common\\FunnyPick\\FunnyPick\\FunnyPick.csproj",
"packagesPath": "C:\\Users\\Feteto\\.nuget\\packages\\",
"outputPath": "D:\\source\\Ftt_Common\\FunnyPick\\FunnyPick\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
],
"configFilePaths": [
"C:\\Users\\Feteto\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"netcoreapp3.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.0": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.0": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.0.100\\RuntimeIdentifierGraph.json"
}
}
}
}
\ 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