草庐IT

email_from

全部标签

c# - Entity Framework 4.1 : Unable to cast from DbQuery to ObjectQuery

我有以下代码:publicvoidDeleteAccountsForMonth(intyear,intmonth){varresult=fromacminthis._database.AccountsOnMonthwhere((acm.Year==year)&&(acm.Month==month))selectacm.Id;varquery=(ObjectQuery)result;stringsql=string.Format("DELETEFROM[AccountsOnMonth]WHERE[AccountsOnMonth].[Id]IN({0})",query.ToTraceStr

c# - 你对 C# 中的 "Escape from Zurg"难题的解决方案是什么?

找到这个谜题HERE...我做了一个蛮力解决方案,我想知道您将如何解决它...Buzz、Woody、Rex和Hamm必须逃离Zurg(a)他们只需要穿过他们获得自由之前的最后一座桥。然而,桥是脆弱的,最多只能支撑他们两个同时。此外,过桥需要手电筒避免陷阱和破损的零件。问题是我们的friend只有一个手电筒用一block只能持续60分钟的电池(这不是打字错误:60)。玩具需要过桥的不同时间(任一方向):TOYTIMEBuzz5minutesWoody10minutesRex20minutesHamm25minutes由于桥上只能同时有两个玩具,所以他们不能越过桥一次桥接。因为他们需要手电

C# 3.0 : Need to return duplicates from a List<>

我在C#中有一个对象列表,我需要一种方法来返回那些在列表中被认为是重复的对象。我不需要Distinct结果集,我需要一个我将从存储库中删除的项目的列表。为了这个例子,假设我有一个“汽车”类型的列表,我需要知道这些汽车中有哪些与列表中的其他汽车颜色相同。以下是列表中的汽车及其颜色属性:Car1.Color=Red;Car2.Color=Blue;Car3.Color=Green;Car4.Color=Red;Car5.Color=Red;对于这个例子,我需要结果(IEnumerable、List或其他)来包含Car4和Car5,因为我想从我的存储库或数据库中删除它们,这样我的存储库中每种

c# - 为什么 Resharper 使用此代码说 "Co-variant array conversion from string[] to object[] can cause run-time exception on write operation"?

这个问题在这里已经有了答案:Co-variantarrayconversionfromxtoymaycauserun-timeexception(7个答案)关闭7年前。这段代码:comboBoxMonth.Items.AddRange(UsageRptConstsAndUtils.months.ToArray());publicstaticListmonths=newList{"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};提示“从string[]到object[]的Co-variant数

C# 2005 : Remove icon from the form's title bar

一位客户要求我从表单的标题栏中删除该图标。因为他们不想显示任何图标。但这我猜是因为当我单击图标属性时,您必须浏览到某个图标。 最佳答案 将表单的ShowIcon属性设置为False以查看这是否是您的客户想要的。 关于C#2005:Removeiconfromtheform'stitlebar,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/784717/

c# - Int 到字符串 : cannot convert from 'method group' to 'string'

这个问题不太可能帮助任何future的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况有关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visitthehelpcenter.关闭9年前。我的表单上有一个listView。我想在程序运行期间向其中添加内容。这是我使用的代码publicvoidFillList(string[]Name,int[]empty,int[]Population,int[]Max,int[]Check,intsize){if(this.InvokeRequired){this.Invoke((MethodInvoke

c# - 单元测试错误 : This function can only be invoked from LINQ to Entities

我正在编写一个MVC5互联网应用程序,我的表达式如下:publicExpression>IsExpiresDateTimeLessThanMinimumDaysLeftInFreeTrialSubscription(intminimumDaysLeftInSubscriptionForEmail){returnAccount=>System.Data.Entity.DbFunctions.DiffHours(Account.freeTrialEndDate,DateTime.UtcNow)从数据库中检索数据时,上述表达式正确完成。但是,在编写使用上述表达式的单元测试时,出现以下错误:T

c# - "Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))"

我正在尝试使用一个应用程序,该应用程序运行良好,我正在尝试编辑应用程序中的现有项目。单击编辑时出现以下错误,System.Runtime.InteropServices.COMExceptionwasunhandledMessage="Classnotregistered(ExceptionfromHRESULT:0x80040154(REGDB_E_CLASSNOTREG))"Source="System.Windows.Forms"ErrorCode=-2147221164StackTrace:atSystem.Windows.Forms.UnsafeNativeMethods.C

c# - ConfigurationManager.GetSection 给出错误 "Could not load type....from assembly..."

我的app.config文件如下:我有以下(单独的)类来获取配置:namespaceConfiguration{usingSystem.Configuration;publicclassProcessesConfigurationSection:ConfigurationSection{[ConfigurationProperty("processes",IsDefaultCollection=false)][ConfigurationCollection(typeof(ProcessCollection))]publicProcessCollectionProcesses{get{r

c# - <in From, out To> 是什么意思?

Resharper建议从interfaceIModelMapper{TToMap(TFrominput);}进入interfaceIModelMapper所以我调查了一下并结束阅读thisarticle(通过Wikipedia文章找到)和更多Google。我仍然不确定这对我的申请意味着什么,所以我很想不接受这个建议。此更改会带来哪些好处,我不会通过忽略该建议来考虑?更明确地说,我为什么要接受它? 最佳答案 底线:Resharper已调查您的类型,并发现TFrom可以逆变地使用,并且TTo协变地。接受重构将使您能够更灵活地使用这些类型