草庐IT

entity-component-system

全部标签

C# System.Object.operator==()

我正在努力了解System.Object.operator==()的使用。我的EffectiveC#书和这里的页面(http://www.srtsolutions.com/just-what-is-the-default-equals-behavior-in-c-how-does-it-relate-to-gethashcode)说:“System.Object.operator==()将调用a.Equals(b)以确定a和b是否相等”。所以我的代码:objecta=1;objectb=1;if(object.Equals(a,b)){//Willgetherebecauseitcal

c# - Entity Framework 4 中的简单条件 LINQ 查询

我最近将这段代码迁移到了EntityFramework4,但失败了。显然,如果status没有值,则返回所有匹配项,如果它有值匹配user.StatusID==1。returnusers.SingleOrDefault(user=>user.Username==username&&user.EncryptedPassword==password&&(!status.HasValue||user.StatusID==1));异常返回:ArgumentException:Thespecifiedvalueisnotaninstanceoftype'Edm.Int32'Parameterna

c# - 有人使用 .NET 的 System.IO.IsolatedStorage 吗?

我在阅读.NET中的System.IO.IsolatedStorage命名空间时发现我可以使用它来将文件存储到我的程序集或可执行文件的唯一位置。例如下面的代码:usingSystem.IO.IsolatedStorage;publicclassProgram{staticvoidMain(string[]args){IsolatedStorageFilestore=IsolatedStorageFile.GetUserStoreForAssembly();store.CreateFile("myUserFile.txt");}}在以下位置创建文件“myUserFile.txt”:C:\

c# - 如何在 Entity Framework 代码优先方法中映射自身的递归关系

我想要创建的只是基本的递归类别。如果RootCategory_Id设置为null,则类别为根;如果设置为某个id,则它属于其他某个类别。我在Seed()方法中添加了带有两个子类别的类别进行测试,但它不起作用。(后来查了DB,有插入)类别模型publicclassCategory{publicintID{get;set;}publicCategoryRootCategory{get;set;}//Thisoneworksgood,italsocreates"RootCategory_Id"indatabaseon"update-database"publicICollectionChil

c# - System.IO.File.Move--如何等待移动完成?

我正在用C#编写一个WPF应用程序,我需要移动一些文件——问题是我真的真的需要知道这些文件是否成功。为此,我写了一个检查以确保文件在移动后到达目标目录——问题是有时我在文件移动完成之前就进行了检查:System.IO.File.Move(file.FullName,endLocationWithFile);System.IO.FileInfo[]filesInDirectory=endLocation.GetFiles();foreach(System.IO.FileInfotempinfilesInDirectory){if(temp.Name==shortFileName){ret

c# - System.IO.Directory.GetFiles 空

当我枚举“C:\Windows\System32\Tasks”时,谁能解释为什么GetFile()为空?System.IO.Directory.GetFiles(@"C:\Windows\System32\Tasks");我检查过这个:VS以管理员身份运行没有抛出异常根目录下有文件我可以(通过资源管理器)将文件复制到另一个文件夹,而且它可以工作 最佳答案 这里的问题是您正在以x86运行程序,它是beingsilentlyredirectedtoanotherfolder里面没有文件。(它将被重定向到C:\Windows\SysWOW

c# - 创建随机颜色 (System.Drawing.Color)

我正在尝试创建随机绘图颜色。有一个错误。你能帮我看看这段代码吗?privateRandomrandom;privatevoidMainForm_Load(objectsender,EventArgse){random=newRandom();}privateColorGetRandomColor(){returnColor.FromArgb(random.Next(0,255),random.Next(0,255),random.Next(0,255));//Theerrorishere}publicSolidBrushbrushGet(){SolidBrushoBrush=newSo

c# - Entity Framework Code First - 两个名称相同但 namespace 不同的实体

我在以下情况下遇到数据库生成问题:1.csFirst.Entities命名空间中的项目实体映射到First_Project表。namespaceFirst.Entities{#regionusingsectionusingSystem.Collections.Generic;usingSystem.ComponentModel.DataAnnotations;usingSystem.Data.Entity.ModelConfiguration;usingSystem.Diagnostics.CodeAnalysis;#endregion[Table("First_Project")]p

c# - Entity Framework 将记录添加到多对多映射表中

我有3个表,1)客户(身份证,姓名,blabla)2)CustomerGroups(GroupId,GroupName)3)CustomerInGroups(CustomerId,GroupId)using(varcontext=DataObjectFactory.CreateContext()){context.Customers.Add(entity);context.SaveChanges();returnentity.Id;}如何将记录添加到CustomerInGroups?EntityFramework不会为这种多对多映射表生成实体编辑:Customer和CustomerGr

c# - 具有 System.Security.Claims 的 .NET Framework 中的复杂声明值

我正在开发一个使用Asp.Net5MVC、Owin和Oauth2不记名token作为身份验证类型的网络应用。在thisguide添加自定义复杂声明Json并成功序列化到Microsoft.IdentityModel.Claims.ClaimsIdentity实例之后,我尝试使用System.Security.Claims命名空间上的ClaimsIdentity复制相同的示例。不幸的是,似乎在complexClaim实例中添加了一个ClaimsIdentity,派生类的类型信息丢失了,声明存储为一个System.Security.Claims.Claim。varcomplexClaim=