entity-framework-4

Generically return an item from Entity Framework

家住魔仙堡 提交于 2019-12-24 03:24:11
问题 I have a situation where a website can ask for data from my database based on a string (don't worry - I'm protecting against SQL injections). For various reasons, I would like to have a single method which returns back the object (from EF) that the user expects (which, ultimately, comes back through a partial page). I'm thinking something like this: public <GenericType?> GetObject(int id, string typeName) { switch(typeName) { case "Type1": return db.Type1s.SingleOrDefault(t => t.TypeID == id)

EF EntityObject not updating databindings of relationships

两盒软妹~` 提交于 2019-12-24 03:04:35
问题 I'm using EntityFramework, WPF and MVVM in my application and got some problems with updating the databinding of relationships between EntityObjects. I was able to downsize my problem to only a few lines of XAML and I hope someone can help me as I'm still not very confident with EF and MVVM. Anyway, here we go with the simplified XAML: <DatePicker Grid.Row="2" Grid.Column="1" SelectedDate="{Binding Path=File.SentDate, StringFormat={}{0:dd/MM/yyyy}, Mode=TwoWay, UpdateSourceTrigger

How to locate the meta files generated by EF in a class library?

僤鯓⒐⒋嵵緔 提交于 2019-12-24 02:55:23
问题 I've moved my Entity Framework 4 model to a class library. The meta files are built to \bin\Debug What is the connection string I use to locate the meta files in the class library? I have tried: <add name="Models.DataModelConnectionString" connectionString="metadata=res://MyClassLibrary, 1.0.0.0, neutral, null/bin/Debug/Models.DataModel.csdl|res://MyClassLibrary, 1.0.0.0, neutral, null/bin/Debug/Models.DataModel.ssdl|res://MyClassLibrary, 1.0.0.0, neutral, null/bin/Debug/Models.DataModel.msl

Entity Framework: Cache management?

北城余情 提交于 2019-12-24 01:16:37
问题 I'm using Entity Framework 4.0 behind WCF services. My problem is that the memory used by the programm is growing a lot(start à 200Mo, and I stopped it at ~1.1Go. How can I manage the cache? I mean, I've two datacontext, one of them is never used to read data, so can I disable the cache? And for the other, can I specify the amount of space it cans use? Is there a way to monitor these resources? Is there a way to use less resources? Thank you! 回答1: First of all you should not use shared

EF: Can I mix TPH and TPT when abstract base and a few concrete types are in TPH-table and other types have their own table?

安稳与你 提交于 2019-12-24 00:32:43
问题 First of all, these questions are similar but definitely not the same: Can I mix Table per Hierarchy and Table per Type in Entity Framework? - Refers to a different scenario. Entity Framework: mix table per type and table per hierarchy - Yet another scenario, that despite accepting answer to first scenario is not related to it (*). (*) Second of all, I have sucessfully mixed table-per-type and table-per-hierarchy in Entity Framework, when base entity is mapped using table-per-entity and the

entity framework - how can I implement this SQL in the abbreviated EF linq

☆樱花仙子☆ 提交于 2019-12-24 00:19:08
问题 Can anyone help out with what the C# code would be to implement this SQL as Entity Framework Linq in the abbreviated form? (e.g. where you have the "." notation such as xxx.where(... etc) SELECT PN.Name, Sum(U.Amount) FROM Usages as U, ProcessNames as PN WHERE PN.Id == U.ProcessNameId AND U.Datetime BETWEEN '2010-01-08' AND '2010-10-11' Group By PN.Name 回答1: Method-Based Query: To implement this in lambda we need to leverage Queryable.GroupJoin: var query = context.ProcessNames .GroupJoin

Changing association property (EntityCollection) don't rise PropertyChanged

我只是一个虾纸丫 提交于 2019-12-24 00:07:41
问题 I want to bind some column data of readonly DataGrid to Association property of Entity through Converter (convert collection from this association property to string). When I try to add/remove elements from collection, binding don't fire. PropertyChanged also, don't rising. contractPosition.PropertyChanged += (s, e2) => { a = 0;//don't fire }; contractPosition.ContractToOrderLinks.Remove(link); Here is the fragment of contractPosition Entity (generated by EF4): [Association("ContractPosition

System.Reflection.ReflectionTypeLoadException with Entity Framework 4

橙三吉。 提交于 2019-12-23 22:36:35
问题 I am using EF4 in windows form app. I got a problem whenever I run a release file in machine which doesn't have visual studio 2010 installed I always got this error : System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information So far, the only workaround is install VS 2010 and rebuild solution in order to make the release run. It's so annoying, I wonder if there is a better solution. 回答1:

Using a List in a where clause in Entity Framework

∥☆過路亽.° 提交于 2019-12-23 21:22:16
问题 I am trying to retrieve document id's over a one-to-many table. I want to use a List in the where clause to find all id's that are connected with every element in the list. List<int> docIds = (from d in doc where _tags.Contains(d.Tags) select d.id).ToList<int>(); I know that the contains must be incorrect but I can't work it out. If I try a foreach I can't work out how to check if the document contains all Tags. 回答1: If you want that all d.Tags should be in the included in the _tags list, you

Entity Framework, SQLite and Lazy loading

断了今生、忘了曾经 提交于 2019-12-23 21:09:58
问题 Hi I had developed a C# Budget application using SQL Compact and EF4, I created the EF model through the VS2010 Entity Data Model template. It is all working very well. However I am considering developing a iPhone app to support cash transactions and thought it would be better to have the back end DB supported on both platforms. After creating the SQLite DB and creating a new model I have come across a problem when trying to access referenced data via the Navigation properties in my model. I