所以我用这样的用户和角色来播种我的数据库。
public static void SeedUsers(this ModelBuilder modelBuilder)
{
var roles = new[]
{
new Role
{
Id = new Guid("5127599a-e956-4f5e-9385-1b8c6a74e4f1"),
RoleName = "Customer"
},
new Role
{
Id = new Guid("8634c476-20fa-4391-b8f7-8713abf61af0"),
RoleName = "Admin"
}
};
// customer password
byte[] customerPasswordHash = null;
byte[] customerPasswordSalt = null;
HashPassword("asd123", out customerPasswordHash, out customerPasswordSalt);
// admin password
byte[] adminPasswordHash = null;
byte[] adminPasswordSalt = null;
HashPassword("asd123", out adminPasswordHash, out adminPasswordSalt);
var users = new[]
{
new Users()
{
Id = new Guid("3b86f5a2-1978-46e3-a0b6-edbb6b558efc"), …
Run Code Online (Sandbox Code Playgroud) c# entity-framework-core .net-core ef-core-2.0 entity-framework-migrations
它可能有点长,但我认为它很容易阅读......所以让我们开始......
我有一个使用IoT Edge Tools创建的 IoT-Edge 解决方案。它生成一个 Dockerfile,该文件非常适合没有外部 DLL 作为依赖项的项目。
当我在这个模块 ( ) 中添加多个 DLL ( MySqlAdapter
, BaseAdapter
, ) 时,问题就出现了,而在尝试构建镜像时没有更改 Dockerfile,Helper
MyEdgeModule
它抛出一个错误:
正在跳过项目“/MySqlAdapter/MySqlAdapter.csproj”,因为找不到它。正在跳过项目“/MySqlAdapter/MySqlAdapter.csproj”,因为找不到它。
...
...:警告:引用的项目“../MySqlAdapter/MySqlAdapter.csproj”不存在。[/app/MyEdgeModule.csproj]
这是生成的 DockerfileMyEdgeModule
FROM microsoft/dotnet:2.1-sdk AS build-env
WORKDIR /app
COPY *.csproj ./
RUN dotnet restore
COPY *.csproj ./
RUN dotnet restore
COPY . ./
RUN dotnet publish -c Release -o out
FROM microsoft/dotnet:2.1-runtime-stretch-slim
WORKDIR /app
COPY --from=build-env /app/out ./
RUN useradd -ms /bin/bash moduleuser
USER moduleuser
ENTRYPOINT ["dotnet", "MyEdgeModule.dll"]
Run Code Online (Sandbox Code Playgroud)
这些类库项目位于 …
所以我正在使用一个API,其中以下列格式检索日期时间 DIE, 28. AUG 2018 12:38:38
我找到的最接近的日期时间格式是这个ddd, dd. MMM yyyy HH:mm:ss
.它只适用于它DI
,但是API提供了这一天DIE
.
是否存在可以解析的格式DIE, 28. AUG 2018 12:38:38
我相信此API的开发人员使用某种不同的格式.
有谁知道它可能是什么?
编辑:我试过的一些代码
static void Main(string[] args)
{
const string DateTimeFormat = "ddd, dd. MMM yyyy HH:mm:ss";
var deCultureInfo = new CultureInfo("de-DE");
string input = "DIE, 28. AUG 2018 14:12:01";
// both throws exception
var timestamp1 = DateTime.ParseExact(input, DateTimeFormat, deCultureInfo);
var timestamp2 = DateTime.Parse(input, deCultureInfo);
//Console.WriteLine(DateTime.Now.ToString(deCultureInfo));
}
Run Code Online (Sandbox Code Playgroud) 我需要创建带有名称的XML标签geo:lat
并geo:long
创建一个GeoRSS提要.但它抛出
':'字符,十六进制值0x3A,不能包含在名称中.
部分代码是这样的:
XElement("geo:lat", item.Latitude);
XElement("geo:long", item.Longitude);
Run Code Online (Sandbox Code Playgroud)
如何在C#中实现这种格式?
<?xml version="1.0"?>
<?xml-stylesheet href="/eqcenter/catalogs/rssxsl.php?feed=eqs7day-M5.xml" type="text/xsl"
media="screen"?>
<rss version="2.0"
xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>USGS M5+ Earthquakes</title>
<description>Real-time, worldwide earthquake list for the past 7 days</description>
<link>https://earthquake.usgs.gov/eqcenter/</link>
<dc:publisher>U.S. Geological Survey</dc:publisher>
<pubDate>Thu, 27 Dec 2007 23:56:15 PST</pubDate>
<item>
<pubDate>Fri, 28 Dec 2007 05:24:17 GMT</pubDate>
<title>M 5.3, northern Sumatra, Indonesia</title>
<description>December 28, 2007 05:24:17 GMT</description>
<link>https://example.com</link>
<geo:lat>5.5319</geo:lat>
<geo:long>95.8972</geo:long>
</item>
Run Code Online (Sandbox Code Playgroud)
我需要最新版本的 SQL LocalDB 以便我可以使用STRING_AGG
函数。
尝试从 SQL Server 2017 Express Installer 下载并安装 LocalDB 后,我有以下版本:
但是当我检查可用版本时,它给出:
最后,如果我用 来创建新实例sqllocaldb create "TestInstance"
,并希望用最新版本来创建它,结果是11.x
:
如何创建 LocalDB 的 2017 实例以便我可以使用STRING_AGG
?
c# ×4
.net-core ×1
cultureinfo ×1
datetime ×1
docker ×1
dockerfile ×1
ef-core-2.0 ×1
entity-framework-migrations ×1
georss ×1
localdb ×1
rss ×1
sql-server ×1
xml ×1