草庐IT

first_gui

全部标签

c# - 如何使用 Entity Framework Code-First 方法将 double[] 数组存储到数据库

如何在不影响现有代码和架构设计的情况下使用EntityFrameworkCode-First将double组存储到数据库?我看过DataAnnotation和FluentAPI,我还考虑过将double组转换为字节字符串并将该字节存储到数据库中它自己的列中。我无法访问publicdouble[]Data{get;放;属性与FluentAPI,然后我得到的错误消息是:Thetypedouble[]mustbeanon-nullablevaluetypeinordertouseitasparameter'T'.存储Data的类已成功存储在数据库中,以及与该类的关系。我只缺少Data列。

c# - EF Code First 延迟加载不起作用

我在EF6中使用代码优先,但似乎无法让延迟加载工作。急切加载工作正常。我有以下类(class):publicclassMerchant:User{...publicvirtualICollectionMerchantLocations{get;set;}}publicclassMerchantLocation:BaseEntity{...publicintMerchantId{get;set;}publicvirtualMerchantMerchant{get;set;}}publicclassUser:BaseEntity{...}publicclassBaseEntity{...p

c# - EF Code First 延迟加载不起作用

我在EF6中使用代码优先,但似乎无法让延迟加载工作。急切加载工作正常。我有以下类(class):publicclassMerchant:User{...publicvirtualICollectionMerchantLocations{get;set;}}publicclassMerchantLocation:BaseEntity{...publicintMerchantId{get;set;}publicvirtualMerchantMerchant{get;set;}}publicclassUser:BaseEntity{...}publicclassBaseEntity{...p

c# - 错误 'there is already an open datareader associated with this command which must be closed first'

运行时错误“已经有一个与此命令关联的打开的数据读取器必须先关闭”objCommand=newSqlCommand("SELECTfield1,field2FROMsourcetable",objConn);objDataReader=objCommand.ExecuteReader();while(objDataReader.Read()){objInsertCommand=newSqlCommand("INSERTINTOtablename(field1,field2)VALUES(3,'"+objDataReader[0]+"')",objConn);objInsertComman

c# - 错误 'there is already an open datareader associated with this command which must be closed first'

运行时错误“已经有一个与此命令关联的打开的数据读取器必须先关闭”objCommand=newSqlCommand("SELECTfield1,field2FROMsourcetable",objConn);objDataReader=objCommand.ExecuteReader();while(objDataReader.Read()){objInsertCommand=newSqlCommand("INSERTINTOtablename(field1,field2)VALUES(3,'"+objDataReader[0]+"')",objConn);objInsertComman

c# - 使用 Entity Framework 4 和 Code-First 从数据库中排除字段/属性

我想知道有没有办法从数据库中排除某些字段?例如:publicclassEmployee{publicintId{get;set;}publicstringName{get;set;}publicstringFatherName{get;set;}publicboolIsMale{get;set;}publicboolIsMarried{get;set;}publicstringAddressAs{get;set;}}如何从数据库中排除AddressAs字段? 最佳答案 供以后引用:可以使用数据注解MSDNEF-CodeFirstDa

c# - 使用 Entity Framework 4 和 Code-First 从数据库中排除字段/属性

我想知道有没有办法从数据库中排除某些字段?例如:publicclassEmployee{publicintId{get;set;}publicstringName{get;set;}publicstringFatherName{get;set;}publicboolIsMale{get;set;}publicboolIsMarried{get;set;}publicstringAddressAs{get;set;}}如何从数据库中排除AddressAs字段? 最佳答案 供以后引用:可以使用数据注解MSDNEF-CodeFirstDa

c# - Entity Framework 6 Code First 函数映射

我想将EntityFramework6集成到我们的系统中,但遇到了问题。我想使用CodeFirst。由于其他原因,我不想使用DatabaseFirst*.edmx文件。我使用属性映射[Table]、[Column],效果很好数据库有很多用户定义的函数,我需要在LinqToEntities查询中使用它们。问题是:我无法通过[Table]、[Column]等属性映射函数。只有1个属性可用[DbFunction],需要*.edmx文件。我可以在*.edmx文件中进行函数映射,但这意味着我不能对实体使用属性映射:[Table]、[Column]。*.edmx或属性中的映射必须完整。我尝试通过以

c# - Entity Framework 6 Code First 函数映射

我想将EntityFramework6集成到我们的系统中,但遇到了问题。我想使用CodeFirst。由于其他原因,我不想使用DatabaseFirst*.edmx文件。我使用属性映射[Table]、[Column],效果很好数据库有很多用户定义的函数,我需要在LinqToEntities查询中使用它们。问题是:我无法通过[Table]、[Column]等属性映射函数。只有1个属性可用[DbFunction],需要*.edmx文件。我可以在*.edmx文件中进行函数映射,但这意味着我不能对实体使用属性映射:[Table]、[Column]。*.edmx或属性中的映射必须完整。我尝试通过以

c# - 将 C# MethodInvoker.Invoke() 用于 GUI 应用程序……这样好吗?

使用C#2.0和MethodInvoker委托(delegate),我有一个GUI应用程序从GUI线程或工作线程接收一些事件。我使用以下模式处理表单中的事件:privatevoidSomeEventHandler(objectsender,EventArgse){MethodInvokermethod=delegate{uiSomeTextBox.Text="sometext";};if(InvokeRequired)BeginInvoke(method);elsemethod.Invoke();}通过使用这种模式,我不会复制实际的UI代码,但我不确定这种方法是否好。特别是行metho