在存储库中,最佳和最合乎逻辑的方法是什么?
使用实体删除还是按ID删除?
public void Delete(Entity item);
VS.
public void Delete(int Id);
Run Code Online (Sandbox Code Playgroud)
我只是想知道什么是最佳实践,应该通过Entity删除(在删除之前先找到对象即可实现)还是通过Id删除(在方法上搜索对象然后删除)。
我在.NET MVC中,我希望像这样读取一个JSON文件:
JSON = System.IO.File.ReadAllText("companyInfo.json");
Run Code Online (Sandbox Code Playgroud)
但是,我无法走上正轨.我不关心我把json文件放在哪里,所以我要求建议放置它的地方以及要使用的路径字符串.
我在c#中遇到了一个被误解的行为.这里是完整的例子Even Resharper告诉我我的期望
using System;
namespace ConsoleApplication11
{
class Program
{
static void Main(string[] args)
{
var str = EmptyArray<string>.Instance;
var intTest = EmptyArray<int>.Instance;
var intTest1 = EmptyArray<int>.Instance;
var str1 = EmptyArray<string>.Instance;
int i=0;
int j = 0;
string s = "";
Console.WriteLine(str.GetType());
Console.WriteLine(intTest.GetType());
if (Object.ReferenceEquals(str,str1))
{
Console.WriteLine("References are equals");
}
if (Object.ReferenceEquals(intTest,intTest1)) ;
{
Console.WriteLine("References are equals");
}
//this will be true so Why ?
if (Object.ReferenceEquals(intTest,str)) ;
{
Console.WriteLine("References are equals");
}
//I know this will be always false …Run Code Online (Sandbox Code Playgroud) 如何从C#中的主线程打开一个新表单?
这时我用这个打开它们:
System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(oppenMainForm));
t.SetApartmentState(ApartmentState.STA);
t.Start();
Run Code Online (Sandbox Code Playgroud)
但是这会创建一个新线程...我的主要表单是我的登录表单..我想要关闭然后打开我的第二个表单.