entity-framework-4

Help testing mvc3 controller that accesses querystring

大城市里の小女人 提交于 2019-12-12 06:31:17
问题 Just started learning mvc3. I've built a fairly basic website (also using EF-Code-First if that makes a difference), now I'm trying to progress to building tests for it My controller gets querystring data by going Request["whatever"] , and when I run the test it says request is null All the tutorials I've looked at so far have kinda lost me. Going into mocks and such, which they seem to assume prior knowledge of (never used mocks, so don't understand them yet) Does anyone have a nice and

EF4 + STE: Reattaching via a WCF Service? Using a new objectcontext each and every time?

偶尔善良 提交于 2019-12-12 06:12:24
问题 I am planning to use WCF (not ria) in conjunction with Entity Framework 4 and STE (Self tracking entitites). If i understnad this correctly my WCF should return an entity or collection of entities (using LIST for example and not IQueryable) to the client (in my case silverlight) The client then can change the entity or update it. At this point i believe it is self tracking???? This is where i sort of get a bit confused as there are a lot of reported problems with STEs not tracking.. Anyway...

Entity Framework 4 and Transactions: Do uncommitted changes affect select results within a transaction?

跟風遠走 提交于 2019-12-12 06:01:16
问题 If I use transactions with Entity Framework 4 like so, will selects on the modified set reflect the newly saved customer IDs within the transaction, or will this generate the same id for each customer? using ( System.Data.Common.DbTransaction trans = new DbTransaction() ) { foreach( var customer in CustomersToSave ) { // Calculate lowest ID available var id_Query = (from c in Customers select c.ID).Distinct(); var lowest_ID_Available = (from p1 in id_Query from p2 in id_Query.Where(a => a ==

How mature & felxible is the Entity Framework's code-first library?

为君一笑 提交于 2019-12-12 05:45:47
问题 I'm getting ready to do a small, brief architecture spike using the EF code-first approach, introduced by Scott Gu here and here. Before I do, I'd like to know whether it will be worth it. Currently I have a project that uses the EF POCO Generation template, and I'd like to investigate the advantages I can get out of switching to a more pure POCO strategy for the domain model. Particularly, these are the things I'm interested in: Avoiding automatically-generated partial classes with

Can I get EnableUpdate and EnableDelete to work on an EF4 LinqDataSource?

浪尽此生 提交于 2019-12-12 05:44:42
问题 So I started using Linq-To-Sql about 2 years ago, but my company is pushing me to switch to Entity Framework v4. Don't want to get into the L2s vs EF arguments here, please just assume that I cannot switch back to L2S. Anyway, in good ol' L2S, I'd define a gridview or listview, then a LinqdataSource with EnableUpdate=true, EnableDelete=true and EnableInsert=true. I'd assign the DataSourceID of teh gridview or listview to the ID of the linqdatasource and BAM! Instant CRUD. With EF4 however, it

Anonymous type and getting values out side of method scope

有些话、适合烂在心里 提交于 2019-12-12 05:39:20
问题 I am building an asp.net site in .net framework 4.0, and I am stuck at the method that supposed to call a .cs class and get the query result back here is my method call and method 1: method call form aspx.cs page: helper cls = new helper(); var query = cls.GetQuery(GroupID,emailCap); 2: Method in helper class: public IQueryable<VariablesForIQueryble> GetQuery(int incomingGroupID, int incomingEmailCap) { var ctx = new some connection_Connection(); ObjectSet<Members1> members = ctx.Members11;

EF4.0 - Is there a way to see what entities are attached to what ObjectContext during debugging?

☆樱花仙子☆ 提交于 2019-12-12 04:38:39
问题 This is in continuation with my problem here. I'm trying to use the solution Julie Lerman gave me a few months ago. I'm currently using the following to generate a new Game entity pre-attached to my ObjectContext: Game game = _gameRepository.GetGame(formData.GameID); AutoMapper.Mapper.Map<AdminGameEditModel, Game>(formData, game); In the repository, I try to attach the Game to the OC with its state set to 'Added' like she suggested by doing the following: public Game GetGame(int id) { if (id

Self referencing model in ASP.NET MVC 3 using Entity Framework

和自甴很熟 提交于 2019-12-12 04:05:30
问题 I have a category class and it can reference itself(only one level up) as parent category. When I retrieve the data using dbContext using Entity Framework, the parent relationship is not loaded. How do I go about achieving that? Here is the class public class Category { [Key] public int CategoryID { get; set; } [Display(Name="Category Name")] public string CategoryName { get; set; } public int ParentCategoryID { get; set; } public virtual Category ParentCategory { get; set; } } when I

Entity Framework 4.0 only include some related data

一世执手 提交于 2019-12-12 03:45:23
问题 I want my query results to only inlcude some of the reated data. For instatnce say I have the entities Sale and Item with each Sale having an Items property which is a list of Item for a particular Sale: from s in myContext.Sales select s; returns all Sales with each Sale containing all Items (when I navigate to Items as LazyLoading is on by default). But I want to only include specifc Items for each Sale - say Items where Name == "Orange" and I still want all Sales. How can I do this? 回答1:

Good Coding Practices [closed]

会有一股神秘感。 提交于 2019-12-12 03:42:21
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I am working on my 2nd project with Entity Framework and I would like to read some opinions about if the code below its good coding