草庐IT

project-name

全部标签

c# - 系统.Data.SqlClient.SqlException : Invalid column name 'phone_types_phone_type_id'

我正在尝试从我的一些模型中获取信息,这些模型与我的主要员工模型具有外键关系。如果我单独绘制每个模型,我可以像往常一样毫无问题地访问它们,但我必须访问多个不同的网页才能这样做。我正在尝试将我的几个模型合并为一个Controller,并以这种方式使用它们。不幸的是,当我尝试访问这些模型时,出现了一个奇怪的错误:System.Data.SqlClient.SqlException:Invalidcolumnname'phone_types_phone_type_id'.搜索我的代码后,显然phone_types_phone_type_id出现的唯一位置是在我的迁移代码中。总的来说,我对C#和

c# - 林克到 SQL : Sort Query by Arbitrary Property(Column) Name

我有一个更大/更复杂的问题,但为了简单起见,让我们考虑以下问题:假设我在SQL数据库中有一个名为Product的表,它有两列,ID(int,primary键)和名称(varchar/string)。我还有一个简单的LINQDataContext。我构造了一个查询并将其交给“我的”函数。让我们假设它是这样的:(虽然它可能有点复杂)IQueryablequery=frompindb.Productsselectp;一旦我的方法得到这个查询,作为参数传入,它必须更改排序顺序,例如IQueryablesortedQuery=query.OrderBy(x=>x.Name);我想让它更通用,即指

c# - 可以在 C# 中使用数组 ['Name' ] 访问的数组

你会吗array['Name'];在C#中而不是:array[0];我知道你可以在PHP中做到这一点,但C#有没有等价物,尽管我认为highley不太可能:( 最佳答案 它叫做Dictionary在C#中。使用泛型,您实际上可以按任何类型进行索引。像这样:Dictionarydictionary=newDictionary();PersonmyPerson=newPerson();dictionary[myPerson]="SomeString";...stringsomeString=dictionary[myPerson];Co

c# - 是否有用于指定属性的 "display name"的 .NET 属性?

是否有允许您为类中的属性指定用户友好名称的属性?例如,假设我有以下类(class):publicclassPosition{publicstringEmployeeName{get;set;}publicContactInfoEmployeeContactInfo{get;set;}}我想指定EmployeeName属性的显示名称是“员工姓名”,EmployeeContactInfo属性的显示名称是“员工联系信息”.编写我自己的允许我这样做的属性类非常容易:[PropertyDisplayInfo(DisplayName="EmployeeName")]publicstringEmpl

c# - 错误 : A project with an out put type of class library

我试图找出.net并得到这段代码,当我尝试从VS2008运行时它给我这个错误AprojectwithanOutputTypeofClassLibrarycannotbestarteddirectly.Inordertodebugthisproject,addanexecutableprojecttothissolutionwhichreferencestothelibraryproject.Settheexecutableprojectasthestartupproject我正在学习C#,所以不知道该做什么 最佳答案 您不能运行库。

c# - 如何覆盖 Razor 的 "name"HtmlAttribute

@Html.RadioButtonFor(Model=>Model.Location,"Location")@Html.LabelFor(Model=>Model.Location,"Location")@Html.RadioButtonFor(Model=>Model.Model,"Model")@Html.LabelFor(Model=>Model.Model,"Model")@Html.RadioButtonFor(Model=>Model.MovableUnit,"MU")@Html.LabelFor(Model=>Model.MovableUnit,"MU")Location

c# - SQLException (0x80131904) : Invalid object name 'dbo.Categories'

我在运行应用程序时遇到上述异常。该应用程序正在使用asp.netmvc3/C#。我制作了一个mdf文件并将其添加到VisualWebDeveloperExpress的App_Data文件夹下。我将连接字符串添加到web.config文件夹,但是当我运行并浏览到/store时,我收到上面的错误,并突出显示varcategories=storeDB.Categories.ToList();行。我的数据库包含6个表,其中一个是类别。Controller:EventCalendarEntitiesstoreDB=newEventCalendarEntities();publicActionRe

c# - "value cannot be null parameter name: key"

我在调试我正在处理的网站时遇到“蓝屏死机”。错误信息是“valuecannotbenull.Parametername:key.”我正在尝试将formview绑定(bind)到gridview的选定索引。当我在我的selectedindexchanged方法中设置断点时,一切似乎都正确绑定(bind),我可以查看我的formview的值,但是当我继续运行它时,我收到上述错误消息。我尝试将datakeynames属性添加到formview并得到相同的错误消息。我在这里和谷歌搜索并看到了一些结果,但似乎没有一个能解决或与我的问题相关。部分代码如下:protectedvoidGridView

c# - EF 5 代码迁移错误 : "There is already an object named _____ in the database"

在进行EF5代码迁移时遇到了一个反复出现的奇怪问题,现在让我无法工作。尝试运行update-database并收到此错误:Thereisalreadyanobjectnamed'RequestStatus'inthedatabase.详细的日志转储:PM>update-database-vUsingStartUpproject'LicensingWorkflow'.UsingNuGetproject'LicensingWorkflow'.Specifythe'-Verbose'flagtoviewtheSQLstatementsbeingappliedtothetargetdataba

c# - "new"inside concrete type projection 只被调用一次

我有简单的Linq2Sql查询:varresult=fromtinMyContext.MyItemsselectnewMyViewModelClass(){FirstProperty=t,SecondProperty=newSomeLinq2SqlEntity()}问题是newSomeLinq2SqlEntity()似乎只对该序列执行一次,因此查询结果中MyViewModelClass的所有实例共享链接到一个对象。更新:这是我快速检查它的方法:result[0].SecondProperty.MyField=10;使用调试器,我可以检查MyField在所有情况下都设置为10。当我用fo