草庐IT

with_entities

全部标签

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# - Entity Framework : Invalid Column after removing the column

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

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# - LINQ 或 ADO.net Entity Framework - 学习哪个?

澄清一点:我在浏览JuliaLerman的OreillyEntityFramework标题时感到非常困惑。我有CharlieCalvert的基本LINQ,但是从我与Lerman的书的10分钟session中,它表明LINQ是LINQtoSQL,它的DataContext对象等似乎功能不足......尽管EntityFramework是future,但它有一个叫做EntitySQL的东西,在我看来它看起来与Transact-SQL完全一样。现在我的眼睛可能有点生锈了,但问题是:既然EntityFramework是Microsoft支持的主力,那么学习LINQtoSQL有什么意义吗varn

c# - 编辑记录时 RadGrid 中的 "Cannot unregister UpdatePanel with ID ' xxx ' since it was not registered with the ScriptManager... "

让我切入正题。我的场景如下:我有自定义添加的字段来过滤RadGrid并且过滤效果很好。当我想在RadGrid中使用EditForm编辑记录时,问题就来了。它过去工作正常,但后来我在选择正确的行时遇到了一些问题(我总是选择错误的行)所以这就是我修复它的方法。所以,我的带过滤器的RadGrid看起来像这样:我所做的是使用session,这将帮助我们稍后确定过滤的RadGrid数据源是已启动还是默认的。protectedvoidbtnSearch_Click(objectsender,EventArgse){Session["SearchKontakti"]="1";}之后,我必须使用if循

c# - .mdf"failed with the operating system error 2(系统找不到指定的文件。)

protectedvoidregister_Click(objectsender,EventArgse){AddUser(userName.Text,password.Text,confirm.Text);}voidAddUser(stringname,stringpass,stringconfirm){Useru=newUser(name,pass,confirm);if(u.Valid){using(vardb=newSiteContext()){db.User.Add(u);db.SaveChanges();}}}}publicclassUser{publicintUserId{

c# - LINQ to Entities 无法识别方法 'System.String get_Item (System.String)' ,

我该如何解决这个问题?这是我的代码:DateTimedtInicio=newDateTime();DateTimedtFim=newDateTime();Int32codStatus=0;if(!string.IsNullOrEmpty(collection["txtDtInicial"]))dtInicio=Convert.ToDateTime(collection["txtDtInicial"]);if(!string.IsNullOrEmpty(collection["txtDtFinal"]))dtFim=Convert.ToDateTime(collection["txtDt

c# - Entity Framework 代码优先 CTP4 默认列值?

我一直在使用EntityFrameworkCTP4研究CodeFirst,您可以使用ModelBuilder来构建您的表列。有没有办法使用ModelBuilder或其他机制为数据库中的列设置默认值?谢谢! 最佳答案 我正在使用构造函数来设置默认值。从来没有让我失望publicclassActivity{[Required]publicDateTimeAddedDate{get;set;}publicActivity(){AddedDate=DateTime.Now;}} 关于c#-Ent

c# - References of References with COM 调用者

这个问题在这里已经有了答案:AddmanagedDLLdependenciedtounmanagedC++project(1个回答)关闭6年前。我有这样一个场景:使用VBA从MSAccess应用程序调用COM调用我们正在构建的C#库,该库引用了Newtonsoft.Jsonv9库使用nuget包,它们自己依赖Newtonsoft.Jsonv6(例如,Microsoft.AspNet.WebApi.Client)当他们尝试使用Newtonsoft.Json(或与我们的C#库引用的版本不同的任何库)时,它自己的黑盒代码中的依赖库会崩溃错误:Couldnotloadfileorassembl