Search Results

Search found 49963 results on 1999 pages for 'entity system'.

Page 19/1999 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >

  • ADO.NET Entity Model and LINQ

    - by Richard
    Hi all I'm using an ADO.NET Entity Model which I'm trying to query using LINQ. The problem I'm having is that I can't specify the where clause as I'd like. For instance, consider the following query: AccountsDM db = new AccountsDM(ConfigurationManager.ConnectionStrings["PrimaryEF"].ConnectionString); var accounts = from a in db.Accounts select a; foreach (var account in accounts) { foreach (var ident in account.Identifiers) { if (ident.Identifier == identifier) { // ident.Identifier is what I'd like to be filtering in the WHERE clause below } } } Ideally, I'd like that to become: var accounts = from a in db.Accounts where a.Identifiers.Identifier == identifier select a; I'm guessing I've probably not set up my Entity Model correctly in VS2010. Any advice you can offer would be gratefully received. Thanks, Richard.

    Read the article

  • Entity framework - exclude list of values

    - by DutrowLLC
    Is there a way to exclude a list of values for an object attribute when querying the database through entity framework? I tried to be slick and pull this number: List<String> StringList = new List<String>(); StringList.Add("ya_mama"); StringList.Add("has"); StringList.Add("fleas"); servicesEntities context = new servicesEntities(); var NoFleasQuery = (from x in context.person where !StringList.Any(y => y.CompareTo(x.the_string_I_dont_want_it_to_be) == 0) // <--- the part where I thought I was slick select x); ...it compiled, but after I ran it, it gave me this error: Unable to create a constant value of type 'Closure type'. Only primitive types ('such as Int32, String, and Guid') are supported in this context. 'Closure type'???? How about MY closure!!! Entity framework... you broke my heart.

    Read the article

  • Entity Framework use of indexes and foreign keys

    - by David
    I want to be able to search a table quite quickly using the Entity Framework, say if I have a Contacts table, a JobsToDo table and a matrix table linking the two tables e.g Contacts_JobsToDo_Mtx and I specify two foreign keys in the Contacts_JobsToDo_Mtx table, if I wanted to search this Mtx table, do I need to specify an index on the two foreign keys? Or by the fact that they are two foreign keys are they considered indexed on them anyway? Will the Entity Framework be able to search through the Mtx table quickly without having to specfiy an index on both keys? Thanks!

    Read the article

  • Need Help on entity framework

    - by Sarathi1904
    I have 3 tables(Roles,Actions and RoleActionLinks). Roles table has few columns(RoleID,RoleName,Desc). Actions table has few colums(ActionID,ActionName,Desc). In RoleActionLink is created for store the association between Roles and Actions and this table has the columns such as RoleID,ActionID When I created the data model(edmx). it shows only Role and Action as entity. i did not find RoleActionLink table. but even there is no direct relation between Roles and Actions table, both tables are automatically related using RoleActionLink table. When i create the new Action, a action record should be populated in Action table(this is works fine). At the same time, i need to populate record in RoleActionLinks table. But i dont have the entity to populate. Please tell me how to accomplish my needs.

    Read the article

  • Entity Fremework serialization

    - by Alexandr
    Hello guys! I was confused with my problem. I'm using Entity Framework and want to save entities on hard disk and then to restore them. I have no problem with Serializing/Deserializing but i get an exception "The object cannot be added to the ObjectStateManager because it already has an EntityKey. Use ObjectContext.Attach to attach an object that has an existing key" when i try to add deserialized object to my datacontext. And nothing happens when i just Attach my entity to datacontext How to achieve my goal? Thx in advance! -Alexandr-

    Read the article

  • ASP.NET MVC & ADO.NET Entity Framework clientside validation

    - by JK
    Using aspnet mvc2 with the model auto-generated by entity framework: Is it possible to tell entity framework to auto-annotate all fields? eg: If database field says not null then add [Required] If DB field is a nvarchar(x) then add [StringLength(x)] And so on? What if the field name contains the string "email" eg CustomerEmail - can I get EF to auto-annotate that with an appropriate annotation ([Regex()] maybe) As I understand it, if the model fields are annotated, and I use both Html.ValidationMessageFor() and use if (ModelState.IsValid) in my controller, then that is all I need to do to have basic clientside input validation working? Thanks

    Read the article

  • EF Code First Detached Entity not updating object reference

    - by Alvaro
    I'm posting the exact entity: public class Person : ContactableEntity { public Plan Plan { get; set; } public int Record { get; set; } public int PersonTypeValue { get; set; } } I'm using the following code to update in a disconected context fashion: public void Update(DbSet MySet, object Obj) { MySet.Attach(Obj); var Entry = this.Entry(Obj); Entry.State = EntityState.Modified; this.SaveChanges(); } This is a method exposed by my dbContext Called this way: PersistentManager.Update(PersistentManager.Personas,UpdatedPersona); The problem is, EF will update any property but the referenced Plan object. Can someone tell me where is the mistake? In advance : the entity reaches the point of update with all the properties correctly set. EF just fails to update the FK in the Database (no exception though)

    Read the article

  • Entity Framework associations killing performance

    - by Chris
    Here is the performance test i am looking at. I have 8 different entities that are table per type. Some of the entities contain over 100 thousand rows. This particular application does several recursive calculations on the client so I think it may be best to preload the data instead of lazy loading. If there are no associations I can load the entire database in about 3 seconds. As I add associations in any way the performance starts to drastically decline. I am loading all the data the same way (just calling toList() on the entity attached to the context). I ran the test with edmx generated classes and self tracking entities and had similar results. I am sure if I were to try and deal with the associations myself, similar to how I would in a dataset, the performance problem would go away. On the other hand I am pretty sure this is not how the entity framework was intended to being used. Any thoughts or ideas?

    Read the article

  • Triggers in Entity Framework - Need advice

    - by jaklucky
    Hi all, I am new to Entity Framework and please pardon my ignorance. We have a simple application written using SQL Server and ADO.Net. Now we have got a new requirement that, whenever a particular rows get updated by our application, some business logic has to happen. I have been looking into Triggers in SQL server and it looks like we can do it using triggers. I am also looking at Entity Framework's OnPropertyChange capability. Is it possible to do it with "OnPropertyChange"? I mean, Can I create a model and implement "OnPropertyChange" method? And when our application modifies the rows using ADO.Net, then will it fire "OnPropertyChange" event so that my custome code in "OnPropertyChange" excutes? Thank you in advance for your inputs, Suresh

    Read the article

  • Dealing with uncertainty in ORM - Entity Framework CodeOnly

    - by Simon Fox
    This is a bit of a strange one but I've just seen something on twitter which kind of baffled me and I'm interested to know more. Rob Conery tweeted the following a couple of hours ago: Class name of the day: "Maybe<T>". Method of the day: "ToMaybe<T>()". He then went on to offer a Tekpub coupon to anyone who could guess where it came from. He linked to a further tweet which had a clue and from that I worked out that it was Entity Framework Code-Only but while trying to determine the usage someone else answered to which Rob replied ...EF CodeOnly - dealing with uncertainty.... So my question boils down to what exactly is he referring to with uncertainty and how does this fit in to Entity Framework Code-Only?

    Read the article

  • "Dealing with uncertainty" - Entity Framework CodeOnly

    - by Simon Fox
    This is a bit of a strange one but I've just seen something on twitter which kind of baffled me and I'm interested to know more. Rob Conery tweeted the following a couple of hours ago: Class name of the day: "Maybe<T>". Method of the day: "ToMaybe<T>()". He then went on to offer a Tekpub coupon to anyone who could guess where it came from. He linked to a further tweet which had a clue and from that I worked out that it was Entity Framework Code-Only but while trying to determine the usage someone else answered to which Rob replied ...EF CodeOnly - dealing with uncertainty.... So my question boils down to what exactly is he referring to with uncertainty and how does this fit in to Entity Framework Code-Only?

    Read the article

  • Using Entity Framework for SQL Compact Edition 3.5 does not respect mode=exclusive property of conne

    - by AJ
    I am using SQL Server Compact 3.5 edition with Entity Framework and I want to have exclusive lock on the database as documented here http://msdn.microsoft.com/en-us/library/ms171817.aspx. However when you pass this in a connection string to Entity Framework it does not respect this at all. An example of the connection string as following private static readonly string _ConnectionStringFormat = @"metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl; provider=System.Data.SqlServerCe.3.5; provider connection string='Data Source={0};Mode=Exclusive'"; If anyone has come across this issue before and have found out how to resolve this, then please let me know. Thanks Aj

    Read the article

  • Can Entity Framework be used for the purpose of entity/schema definition at application runtime?

    - by Kabeer
    Hello. Can 'Entity Framework' be used for the purpose of entity definition at application runtime? Ok, to make it simple, here is what I want to achieve: My application is a product. I should be able to define entities at runtime on the basis of inputs gathered from an 'authoring' user (in effect this means 'model first' approach). These entities are of course persistable. Further, after having defined the entities and their relationships, I should be able to make complex queries across them for many reasons, including reports. Is the above possible and how? So far what I have realized is that there is a dependency on Visual Studio.

    Read the article

  • MVC Entity Model not showing my table

    - by Jessica
    I have a database with multiple tables, and some basic relationships. Here is an example of the problem I am having: My Database: **Org** ID Name etc **Detail1** ID D1name **Org_Detail1** Org_ID Detail1_ID **Detail2** ID D2Name **Org_Detail2** Org_ID Detial1_ID BooleanField My problem is, the Org_detail1 table is not showing up in the entity model, but the Org_Details2 table does. I thought it may have been because the Org_Detail1 table only contains two ID fields that are both primary keys, while the Org_Details2 table contains 2 primary key ID fields as well as a boolean field. If I add a dummy field to Org_detail1 and update it, it still won't show up and wont allow me to add a new entity relating to the Org_Detail1 table. The table won't even show up in the list, but it is listed under the tables. Is there any solution to get this table to appear in my model?

    Read the article

  • MVC Entity Framework Model not returning correct data

    - by quagland
    Hi, Run into a strange problem while writing an ASP.NET MVC site. I have a view in my SQL Server database that returns a few date ranges. The view works fine when running the query in SSMS. When the view data is returned by the Entity Framework Model, It returns the correct number of rows but some of the rows are duplicated. Here is an example of what I have done: SQL Server code: CREATE TABLE [dbo].[A]( [ID] [int] NOT NULL, [PhID] [int] NULL, [FromDate] [datetime] NULL, [ToDate] [datetime] NULL, CONSTRAINT [PK_A] PRIMARY KEY CLUSTERED ([ID] ASC)) ON [PRIMARY] go CREATE TABLE [dbo].[B]( [PhID] [int] NOT NULL, [FromDate] [datetime] NULL, [ToDate] [datetime] NULL, CONSTRAINT [PK_B] PRIMARY KEY CLUSTERED ( [PhID] ASC )) ON [PRIMARY] go CREATE VIEW C as SELECT A.ID, CASE WHEN A.PhID IS NULL THEN A.FromDate ELSE B.FromDate END AS FromDate, CASE WHEN A.PhID IS NULL THEN A.ToDate ELSE B.ToDate END AS ToDate FROM A LEFT OUTER JOIN B ON A.PhID = B.PhID go INSERT INTO B (PhID, FromDate, ToDate) VALUES (100, '20100615', '20100715') INSERT INTO A (ID, PhID, FromDate, ToDate) VALUES (1, NULL, '20100101', '20100201') INSERT INTO A (ID, PhID, FromDate, ToDate) VALUES (1, 100, '20100615', '20100715') INSERT INTO B (PhID, FromDate, ToDate) VALUES (101, '20101201', '20101231') INSERT INTO A (ID, PhID, FromDate, ToDate) VALUES (2, NULL, '20100801', '20100901') INSERT INTO A (ID, PhID, FromDate, ToDate) VALUES (2, 101, '20101201', '20101231') So now, if you select all from C, you get 4 separate date ranges In the Entity Framework Model (which I call 'Core'), the view 'C' is added. in MVC Controller: public class HomeController : Controller { public ActionResult Index() { CoreEntities db = new CoreEntities(); var clist = from c in db.C select c; return View(clist.ToList()); } } in MVC View: @model List<RM.Models.C> @{ foreach (RM.Models.C c in Model) { @String.Format("{0:dd-MMM-yyyy}", c.FromDate) <span>-</span> @String.Format("{0:dd-MMM-yyyy}", c.ToDate) <br /> } } When I run all this, it outputs this: 01-Jan-2010 - 01-Feb-2010 01-Jan-2010 - 01-Feb-2010 01-Aug-2010 - 01-Sep-2010 01-Aug-2010 - 01-Sep-2010 When it should do this (this is what the view returns): 01-Jan-2010 - 01-Feb-2010 15-Jun-2010 - 15-Jul-2010 01-Aug-2010 - 01-Sep-2010 01-Dec-2010 - 31-Dec-2010 Also, I've run the SQL profiler over it and according to that, the query being executed is: SELECT [Extent1].[ID] AS [ID], [Extent1].[FromDate] AS [FromDate], [Extent1].[ToDate] AS [ToDate] FROM (SELECT [C].[ID] AS [ID], [C].[FromDate] AS [FromDate], [C].[ToDate] AS [ToDate] FROM [dbo].[C] AS [C]) AS [Extent1] Which returns the correct data So it seems that the entity framework is doing something to the data in the meantime. To me, everything looks fine! Have I missed something? Cheers, Ben

    Read the article

  • Entity Framework 4.1 (Code First) audit column

    - by Ken Pespisa
    I'm using Entity Framework 4.1 with a Code-First approach on an ASP.NET MVC site Say I have an entity named Profile that keeps track of a user's favorite book, and I want to track when the user updates their favorite book. UPDATED: Using the class below as an example, I want to set the FavoriteBookLastUpdated property to the current date whenever the value of the FavoriteBook property changes. public class Profile { public int Id { get; set; } public string Name { get; set; } public string FavoriteBook { get; set; } public DateTime? FavoriteBookLastUpdated { get; set; } } Right now I just update that field, if appropriate, in the controller's Edit action before calling the DBContext's SaveChanges() method. Is there a way I can put that logic in my model somehow? I'd prefer not to use triggers on the database side.

    Read the article

  • what is a performance way to 'tree-walking' through my Entity Framework data

    - by Greg
    Hi, I have a Entity Framework design with a few tables that define a "graph". So there can be a large chain of relationships between objects in the few tables via concept of parent/child relationships. What is a performance way to 'tree-walking' through my Entity Framework data? That is I assume I wouldn't want to load the full set of all NODES and RELATIONSHIPS from the database for the purpose of walking the tree, where the end result may only be identifying leaf nodes? Or would this be OK with the way lazy loading may work at the column/parameter level? Else how could I load just the skeleton of the objects and then when needing to refer to any attributes have them lazy load then?

    Read the article

  • Entity framework and database logic.

    - by Xavier Devian
    Hi all, i have a question that's being around for several years. As all you know entity framework is an ORM tool that tries to model the database to an object oriented access model. All the samples I've seen are quering directly to the database tables. So, which is the role of the views in the database now?. The views were used to model the database in a more friendly way, that is, several physical tables, one logic table. This was great for example in hidding the complex relational model on stored procedures as queryng the views inside them was much easier than reproducing the query joins over and over on each stored procedure. So the question is, why is entity framework so good if stored procedures can not take benefit of it?

    Read the article

  • Entity Framework: Setting EntityReference EntityKey causes exception on save

    - by NYSystemsAnalyst
    I have a table with a ModifiedUserID field that is a foreign key to a User table. In entity framework, I'm loading the first table, but not the users table. I have the user ID of the current user, and would like to set the ModifiedUserID to that value for all entities that have been modified prior to saving. Before calling SaveChanges(), I use the ObjectStateManager to get all modified entities. Since I do not have the user object, but I do have the user ID, I set the EntityReference.EntityKey property as follows: entity.UserReference.EntityKey = New EntityKey("MyContainer.User", "UserID", DatabaseUserID) This works fine, but when I execute SaveChanges(), I receive the following error: A relationship is being added or deleted from an AssociationSet 'FK_Table1_User'. With cardinality constraints, a corresponding 'Table1' must also be added or deleted. Now, I see that setting the EntityReference.EntityKey creates a new AssociationSet entry, but how to I prevent this error?

    Read the article

  • Accessing non-related entities in LinqToSql entity classes

    - by Chris Johnson
    In LinqToSql, if I want to access a non-related entity in an entity partial class, how do I do this without creating a new DataContext? Here's the scenario: I have the tables Client, IssueType and ClientIssueType. A Client may specify a list of IssueTypes if they do not want to use the default IssueTypes. I have the default IssueTypes in the ClientIssueType table with a ClientId of null. In my Client partial I'd like to try to retrieve all IssueTypes, and if none are found, return all default IssueTypes. The only way I can see of accessing the IssueTypes with a null ClientId is by accessing the table through a new DataContext, which is problematic once I want to start assigning them to Issues. Where am I going wrong?

    Read the article

  • Entity Framework This property descriptor does not support the SetValue

    - by Gayan
    Hello guys, below are my entities which i have created using entity frame work. retailer id name childs(navigation) generated database schema [Id] [int] IDENTITY(1,1) NOT NULL, [Name] nvarchar NOT NULL childern id name RETAILER(navigation) generated database schema [Id] [int] IDENTITY(1,1) NOT NULL, [name] nvarchar NOT NULL [Retailer_Id] [int] NOT NULL, As you can see in the above model the relationship is 1 retailer can have 0 or 1 child. my problem is when i create a new child and set the retailer navigation property of it to a retailer entity it throws the following exception.how do i solve it Error while setting property 'retailer': 'This property descriptor does not support the SetValue method.'.

    Read the article

  • Entity framework using Data Repository pattern

    - by JamesStuddart
    Hi all, I have been implementing a new project which I have decided to use the repository pattern and Entity Framework. I have sucessfuly implemented basic CRUD methods and I have no moved onto my DeepLoads. From all the examples and documentation I can find to do this I need to call something like this: public Foo DeepLoadFoo() { return (from foobah in Context.Items.Include("bah").Include("foo").Include("foofoo") select foo).Single(); } This doesnt work for me, maybe I am trying to be too lazy but what I would like to achieve would be something along the lines of this: public Foo DeepLoadFoo(Foo entity, Type[] childTypes) { return (from foobah in Context.Items.Include(childTypes).Single(); } Is anything like this possible, or am I stuck with include.include.include.include? Thanks

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >