草庐IT

entity-system

全部标签

c# - 具有多个 OR 条件的 Linq to Entity Join 表

我需要编写一个Linq-Entity状态来获取下面的SQL查询SELECTRR.OrderIdFROMdbo.TableOneRRJOINdbo.TableTwoMONRR.OrderedProductId=M.ProductIDORRR.SoldProductId=M.ProductIDWHERERR.StatusIDIN(1,4,5,6,7)我被下面的语法困住了int[]statusIds=newint[]{1,4,5,6,7};using(Entitiescontext=newEntities()){varquery=(fromRRincontext.TableOnejoinMi

c# - modelBuilder.Configurations.Add 和 modelBuilder.Entity onModelCreating

我刚刚开始研究EntityFramework代码优先方法,我在下面编写了两种方法并且都运行良好。请告诉我这两种方法背后的核心概念是什么,应该遵循什么?方法1:使用EntityTypeConfigurationpublicclassBlogsMap:EntityTypeConfiguration{publicBlogsMap(stringschema){ToTable("BLOG");HasKey(t=>t.BlogId);Property(t=>t.BlogId).HasColumnName("BLOGID");Property(t=>t.Name).HasColumnName("NA

c# - 如何使用 Entity Framework 4 Code First (POCO) 声明一对一关系

如何使用EntityFramework4CodeFirst(POCO)声明一对一关系?我找到了thisquestion(one-to-onerelationshipsinEntityFramework4),但是答案引用的那篇文章没有用(有一行代码是一对一的关系,但是没有提到如何定义)。 最佳答案 三种方法:A)声明两个具有导航属性的类。用ForeignKey属性标记其中一个表(从属表)的主键。EF从中推断出1对1:publicclassAppUser{publicintId{get;set;}publicstringUsername

c# - mscorlib.dll 中发生类型为 'System.StackOverflowException' 的未处理异常

我在asp.net中写了一段代码,从文件中读取数据并绘制图表。它工作了,但是当我运行程序一段时间后,出现了这个异常"Anunhandledexceptionoftype'System.StackOverflowException'occurredinmscorlib.dll"在代码中的这条语句中:if(File.Exists(fName)) 最佳答案 您的函数可能无限次地递归调用自身。有时这会间接发生(您在BCL中调用一个方法,它会回调您的代码,这样会不断重复)。File.Exists可能不是罪魁祸首。发生错误时查看您的调用堆栈。

c# - 将 Color 转换为像 #XXXXXX 这样的字符串到 System.Windows.Media.Brush 的最简单方法

我觉得标题很清楚!我现在拥有的是:System.Drawing.Coloruiui=System.Drawing.ColorTranslator.FromHtml(myString);varintColor=(uint)((uiui.A1-myString就像我在标题中所说的#FFFFFF2-这在BitConverter.GetBytes行上失败了,这让我感到惊讶,因为我在Color上得到了int表示!3-无论如何,我知道颜色转换不是那么直观,但我觉得我做的不对...这是好方法吗? 最佳答案 您可以使用System.Windows.

c# - Entity Framework : Invalid Column after removing the column

我在EntityFramework中映射了一个表,它非常适合添加/更新和删除记录。我从SQL服务器中删除了一个名为“Category”的列,然后在模型中重新映射了我的实体。这工作正常,该列消失了。现在,我在表上运行查询以更新一行并得到相同的错误,列“类别”无效。这已经从SQL表中删除并从实体中删除,所以当我运行以下代码时它还在寻找这个该死的列吗??using(Entitiesdb=newEntities()){varVoucher=(fromvouchersindb.Voucherswherevouchers.ID==IDselectvouchers).FirstOrDefault()

c# - “模型”与声明“System.Web.Mvc.WebViewPage<TModel>.Model”冲突

我想显示以下客户对象。publicClassCustomer{publiclongId{get;set;}publicstringName{get;set;}publicAddressAddressInfo{get;set;}}publicclassAddress{publicstringDetails{get;set;}publicCityCityInfo{get;set;}publicRegionRegionInfo{get;set;}}并且有一个Controller返回给客户查看publicActionResultGetCustomer(longId){returnView("C

c# - Entity Framework 4 : How to find the primary key?

我正在尝试使用EF4创建一个通用方法来查找对象的主键。例子publicstringGetPrimaryKey(){...}为了提供更多信息,我正在使用TekpubStarterKit,下面是我正在尝试启动和运行的类(class)usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Data.Objects;usingSystem.Data.Objects.ELinq;usingSystem.Data.Linq;usingWeb.Infrastructure.Sto

c# - 使用 XAML 将 System.Drawing.Image 绑定(bind)到 System.Windows.Image 控件中

我正在将一个ListView绑定(bind)到一个对象列表,就像这样;我正在绑定(bind)一个声明了两个属性的对象;stringDisplayName{get;}System.Drawing.ImageImage{get;set;}我想填充一个DataTemplate但我不知道该怎么做;如果我在我的模板中这样做;文本出现但图像不出现。我究竟做错了什么?调试输出显示System.Windows.DataError:1:Cannotcreatedefaultconvertertoperform'one-way'conversionsbetweentypes'System.Drawing.

c# - 隐式转换为 'System.IDisposable' 错误

这就是我想要做的:privateKinectAudioSourceCreateAudioSource(){varsource=KinectSensor.KinectSensors[0].AudioSource;source.NoiseSuppression=_isNoiseSuppressionOn;source.AutomaticGainControlEnabled=_isAutomaticGainOn;returnsource;}privateobjectlockObj=newobject();privatevoidRecordKinectAudio(){lock(lockObj)