Search Results

Search found 9916 results on 397 pages for 'entity component'.

Page 50/397 | < Previous Page | 46 47 48 49 50 51 52 53 54 55 56 57  | Next Page >

  • Entity Framework - Why does EF use LEFT OUTER JOIN's in a 1-to-1 relationship?

    - by Taylor L
    Why does .NET Entity Framework produce SQL that uses a subquery and left outer join on a simple 1-to-1 relationship? I expected to see a simple join on the two tables. I'm using Devart Dotconnect for Oracle. Any ideas? Below is the output I see courtesy of the EFTracingProvider: SELECT 1 AS C1, "Join1".USER_ID1 AS USER_ID, ... FROM "MY$NAMESPACE".MYTABLE1 "Extent1" INNER JOIN (... FROM "MY$NAMESPACE".MYTABLE2 "Extent2" LEFT OUTER JOIN "MY$NAMESPACE".MYTABLE1 "Extent3" ON "Extent2".OTHER_ID = "Extent3".OTHER_ID ) "Join1" ON "Extent1".OTHER_ID = "Join1".OTHER_ID1 WHERE "Extent1".USER_ID = :EntityKeyValue1 -- EntityKeyValue1 (dbtype=String, size=6, direction=Input) = "000000"

    Read the article

  • Get correct output from UTF-8 stored in VarChar using Entity Framework or Linq2SQL?

    - by jasonpenny
    Borland StarTeam seems to store its data as UTF-8 encoded data in VarChar fields. I have an ASP.NET MVC site that returns some custom HTML reports using the StarTeam database, and I would like to find a better solution for getting the correct data, for a rewrite with MVC2. I tried a few things with Encoding GetBytes and GetString, but I couldn't get it to work (we use mostly Delphi at work); then I figured out a T-SQL function to return a NVarChar from UTF-8 stored in a VarChar, and created new SQL views which return the data as NVarChar, but it's slow. The actual problem appears like this: “description†instead of “description”, in both SSMS and in a webpage when using Linq2SQL Is there a way to get the proper data out of these fields using Entity Framework or Linq2SQL?

    Read the article

  • How can i query for null values in entity framework?

    - by AZ
    I want to execute a query like this var result = from entry in table where entry.something == null select entry; and get an IS NULL generated. Edited: After the first two answers i feel the need to clarify that I'm using Entity Framework and not Linq to SQL. The object.Equals() method does not seem to work in EF. Edit no.2: The above query works as intended. It correctly generates IS NULL. My production code however was var value = null; var result = from entry in table where entry.something == value select entry; and the generated SQL was something = @p; @p = NULL. It seems that EF correctly translates the constant expression but if a variable is involved it treats it just like a normal comparison. Makes sense actually. I'll close this question

    Read the article

  • Query data using LINQ to SQL and Entity Framework with foreign key? (Help me please)

    - by The Wind
    Hello! There is a problem I need help with your query on the data using LINQ to SQL and Entity Framework (I'm using Visual Studio 2010). My picure here: http://img.tamtay.vn/files/photo2/2010/5/28/10/962/4bff3a3b_1093f58f_untitled-1.gif I have three tables: tbl NewsDetails tblNewsCategories tblNewsInCategories (See screen 1 in my picture) Now, I want to retrieve records in the tblNewsDetails table, with condition: CategoryId=1, as the following results: (See screen 2 in my picture) But NewsID and CategoryId in tblNewsInCategories table is two foreign key, I do not see them and I do not know how to use them in your code. My code has errors: (See screen 3 in my picture) Please help me. Thanks! (I am a new member, should not have the right to insert images)

    Read the article

  • Is the first persistance of an Entity Data Model in EF 4.0 slower due to the connection cost ?

    - by Scott Davies
    Hi, I've got a console app written that persists an object graph via Entity Framework 4.0. I loop through this to dump the execution times for each persistance. The first persistance is always the largest. Is this due to EF making the initial connection to the database and/or JIT'ing ? Here's a sample of the output: Persisted graph in **3318** millseconds. Persisted graph in 25 millseconds. Persisted graph in 26 millseconds. Persisted graph in 22 millseconds. Thanks, Scott

    Read the article

  • How to organize asp.net mvc project (using entity framework) and a corresponding database project?

    - by Bernie
    I recently switched to vs2010 and am experimenting with asp.net MVC2. I am building a simple website and use the entity framework to design the data model. From the .edmx file, I generate the database tables. After a few iterations, I decided that it would be nice to have version control of the database schema as well, and therefore I added a database project into which I imported the script that is generated from the datamodel. As a result, I have to generate the sql every time that I change the model and redo the import. The database project automatically updates the database. Although the manual steps to generate the sql and the import are annoying, this works pretty well, until I wanted to add the standard tables for user accounts/authorization etc. I can use the framework tools to add the necessary tables, views etc. to the database, but as I do not want to have them in the .edmx model I end up with a third manual step. Is anybody facing similar issues?

    Read the article

  • What is the best way to implement an object cache with Entity Framework?

    - by Harshal
    Say I have a table of "BlogPosts" in a database and i want to be able to cache the ones that were retrieved already in memory, for further reads, I can just use a standard hashtable type memory cache like System.Web.Caching.Cache, but if i then need to update a property on one of these blog posts e.g. blogPost.Title and update the record in DB, i cannot do this without fetching it again from database as the Entity Framework context used to fetch this record when it was loaded into my cache is already disposed? How do I write code so that I am getting an object from my cache, updating one property and just calling the SaveChanges method without incurring an extra read.

    Read the article

  • Entity framework (3.5): How to translate a certain LINQ query to eSQL?

    - by Sebastian P.R. Gingter
    Hi there, I have the following LINQ query that I need to translate to Entity SQL /eSQL): return (ObjectQuery<User>) from user in Users where !user.Roles.Any(r => r.AnIntegerProperty < 0) select user; User.Roles is an navigation property to the n:m relation to Roles and there also is a Role.Users navigation property the other way round. There aren't User_Roles or Roles_User Entities available in the model, and I can't add these. I also can't use the LINQ statement here, because I need to add .OrderBy("it." + propertyname) (comes from another source, can't change that too) later on which is not possible if the ObjectQuery is build with linq. So how do I translate this to eSQL? And where can I find good eSQL samples? I searched for a whole day until now and must admit that eSQL reference is lousy and there aren't any usable examples around the web.

    Read the article

  • What's all the hype over objectsets in Entity Framework 4?

    - by Kohan
    I am an intermediate user of EF in .net 3.5 and have recently moved to working with .net 4. One thing i keep coming across when reading various tutorials is the use of ObjectSets instead of ObjectQuerys and that they are a great new feature. What is so great about them? Reading this MSDN article titled "Working with ObjectSet (Entity Framework)" It shows two examples on how to add a Product.. one for 3.5 and another for 4.0. http://msdn.microsoft.com/en-us/library/ee473442.aspx Through my lack of knowledge I am possibly bringing up a seperate point here, but i never added a Product like this: //In .NET Framework 3.5 SP1, use the following code: using (AdventureWorksEntities context = new AdventureWorksEntities()) { // Add the new object to the context. context.AddObject("Products", newProduct); } I would have just used context.AddToProducts(newProduct); Please enlighten me. Kind regards, Kohan

    Read the article

  • How to ask database server for current datetime using entity framework?

    - by Levelbit
    I don't want for my current ModifeidDateTime to be machine time already server time. Every time I want to update or add a person to my datebase on SQL Server 2008 I want to fill ModifiedDateTime filed. It's not like I can change update query as with data adapter command when I work with dataset and to define for my ModifiedDateTime filed to be =GetDate(). I created stored function to retutn me a value of GetDate() method, but I have a problem to import procedure which returns values as int, string ... or no value at all, already just entity values as Person for example in my case. Why is that? Anyway, It would be of great help if you can provide me any solution that works to retrieve DateTime value from server.

    Read the article

  • How does Hibernate detect dirty state of an entity object?

    - by ???'Lenik
    Is it using some kind of byte codes modification to the original classes? Or, maybe Hibernate get the dirty state by compare the given object with previously persisted version? I'm having a problem with hashCode() and equals() methods for complicated objects. I feel it would be very slow to compute hash code if the object has collection members, and cyclic references are also a problem. If Hibernate won't use hashCode()/equals() to check the dirty state, I guess I should not use equals()/hashCode() for the entity object (not value object), but I'm also afraid if the same operator (==) is not enough. So, the questions are: How does Hibernate know if a property of an object is changed? Do you suggest to override the hashCode()/equals() methods for complicated objects? What if they contains cyclic references? And, also, Would hashCode()/equals() with only the id field be enough?

    Read the article

  • VS 2010 Entity Repository Error Class member EntityBase.id is unmapped.

    - by Steve
    In my project I have it set up so that all the tables in the DB has the property "id" and then I have the entity objects inherit from the EntityBase class using a repository pattern. I then set the inheritance modifier for "id" property in the dbml file o/r designer to "overrides" Public MustInherit Class EntityBase MustOverride Property id() As Integer End Class Public MustInherit Class RepositoryBase(Of T As EntityBase) Protected _Db As New DataClasses1DataContext Public Function GetById(ByVal Id As Integer) As T Return (From a In _Db.GetTable(Of T)() Where a.id = Id).SingleOrDefault End Function End Class Partial Public Class Entity1 Inherits EntityBase End Class Public Class TestRepository Inherits RepositoryBase(Of Entity1) End Class the line Return (From a In _Db.GetTable(Of T)() Where a.id = Id).SingleOrDefault however produces the error "Class member EntityBase.id is unmapped" when i use VS 2010 using the 4.0 framework but I never received that error with the old one. Any help would be greatly appreciated. Thanks in advance.

    Read the article

  • What's the best way to share one Entity Framework 4 data model among multiple applications (meant to

    - by Ivan
    A project (a "solution" to say in VS terms) of mine consists of an ASP.Net 4 Dynamic Data Entities web application, some WinForms applications, some WPF applications, some services. All they are intended to work with one SQL Server database, generated from an Entity Framework 4 model as table-per-type, with lots of inheritance and multiple self-referencing relations. Where do I best put my model? In a separate class library, a copy in every project, in one project, etc. What naming should I best use? Is it good idea to name it MySolution.MyClassLibrary.MySolutionEntities, or just MySolutionEntities or just MySolution? Can you share any useful experience on this subject?

    Read the article

  • Is there a function similar to Math.Max for Entity Framework?

    - by Ryan ONeill
    I have an entity framework query as follows; From T In Db.MyTable Where (T.Col1 - T.Col2) + T.Col3 - T.Col4 > 0 _ Select T I now need to make sure that the bracketed part '(T.Col1 - T.Col2)' does not go below zero. In .Net, I'd code it as follows (but obviously EF does not like Math.Max). From T In Db.MyTable Where Math.Max(T.Col1 - T.Col2,0) + T.Col3 - T.Col4 > 0 _ Select T Is there an easy way to do this? I am using EF 2.0 (not the latest, just released version). Thanks in advance

    Read the article

  • C# / Entity Framework / Linq question regarding calling a method when a class is accessed...

    - by Daniel
    So this is probably really basic, but I'm fairly new to all this. I am using Entity Framework with POCO entities. I want to call a method when a class property is set. I am trying to build an advertisement platform. I have a Customer class, a Venue class and an Advertisement class. I have my indexes set up in such a way that I can call customer.venue. However, I want to be able to call Customer.Venue.CurrentAdvertisement and have it execute a method (if CurrentAdvertisement is null) and return the current advertisement. I know I can explicitly set it every time, but I want to be able to override my classes so that whenever the CurrentAdvertisement property is accessed via LINQ it runs that method to return an ad. In order to do this I need to pass the Venue class a variable (venue name).

    Read the article

  • Can't update rows in my database using Entity Framework...?

    - by Dissonant
    Okay, this is really weird. I made a simple database with a single table, Customer, which has a single column, Name. From the database I auto-generated an ADO.NET Entity Data Model, and I'm trying to add a new Customer to it like so: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Test { class Program { static void Main() { Database1Entities db = new Database1Entities(); Customer c = new Customer(); c.Name = "Harry"; db.AddToCustomer(c); db.SaveChanges(); } } } But it doesn't persist Customer "Harry" to the database! I've been scratching my head for a while now wondering why such a simple operation doesn't work. What on earth could be the problem!?

    Read the article

  • How do I tell Entity Framework that a column in a view is nullable?

    - by Ryan ONeill
    I have a view which has an Int column which is nullable (let's call it StackOverflowCount). When generating an EF model from the database, the EF designer does not recognise it as nullable and creates the column as an Int. The issue I have is that on the EF designer I have set the column to Nullable and the following error then kills the compilation; Error 3031: Problem in mapping fragments starting at line 2327: Non-nullable column MyView.StackOverflowCount in table MyView is mapped to a nullable entity property. I can get round this by opening the .edmx file in XML mode and manually editing the SQL column definition, but there is no way to do this using the designer and it gets overwritten the next time I refresh from the model from the DB. Is this 'by design' or an example of something that slipped through into EF 4.0? I'm using .Net 4.0 with EF 4.0 under VS 2010.

    Read the article

  • How do I delete an object from an Entity Framework model without first loading it?

    - by Tomas Lycken
    I am quite sure I've seen the answer to this question somewhere, but as I couldn't find it with a couple of searches on SO or google, I ask it again anyway... In Entity Framework, the only way to delete a data object seems to be MyEntityModel ent = new MyEntityModel(); ent.DeleteObject(theObjectToDelete); ent.SaveChanges(); However, this approach requires the object to be loaded to, in this case, the Controller first, just to delete it. Is there a way to delete a business object referencing only for instance its ID? If there is a smarter way using Linq or Lambda expressions, that is fine too. The main objective, though, is to avoid loading data just to delete it.

    Read the article

  • Should i use partial classes as business layer when using entity framework?

    - by samsur
    I am working on a project using entity framework. Is it okay to use partial classes of the EF generated classes as the business layer. I am begining to think that this is how EF is intended to be used. I have attempted to use a DTO pattern and soon realized that i am just creating a bunch of mapping classes that is duplicating my effort and also a cause for more maintenance work and an additional layer. I want to use self-tracking-entities and pass the EF entities to all the layers. Please share your thoughts and ideas. Thanks

    Read the article

  • Is LocalDB supported by Visual Studio 2010 in Entity Framework 5?

    - by Mathias Lykkegaard Lorenzen
    Is LocalDB supported by Visual Studio 2010 in Entity Framework 5, on .NET 4.0? Or am I doing it wrong? I'm getting a "The network path can't be found" issue when instantiating my model container with a connection string for LocalDB. Here's the connection string: var connectionString = "metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string=\"data source=(localdb)\v11.0;initial catalog=fablelane_com_db;integrated security=SSPI;multipleactiveresultsets=True;App=EntityFramework\""; Edit 1 I'm receiving the following error when connecting, more specifically: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server). Edit 2 I just figured out that changing to Visual Studio 11 beta doesn't work either. Still receiving the same error-message.

    Read the article

  • Entity diagram with tables that have foreign keys that point to a non-PK column do not show relation

    - by Jason Coyne
    I have two tables parent and child. If I make a foreign key on child that points to the primary key of parent, and then make an entity diagram, the relationship is shown correctly. If I make the foreign key point to a different column, the relationship is not shown. I have tried adding indexes to the column, but it does not have an effect. The database is sqlite, but I am not sure if that has an effect since its all hidden behind ADO.net. How do I get the relationship to work correctly?

    Read the article

  • How should an object that uses composition set its composed components?

    - by Casey
    After struggling with various problems and reading up on component-based systems and reading Bob Nystrom's excellent book "Game Programming Patterns" and in particular the chapter on Components I determined that this is a horrible idea: //Class intended to be inherited by all objects. Engine uses Objects exclusively. class Object : public IUpdatable, public IDrawable { public: Object(); Object(const Object& other); Object& operator=(const Object& rhs); virtual ~Object() =0; virtual void SetBody(const RigidBodyDef& body); virtual const RigidBody* GetBody() const; virtual RigidBody* GetBody(); //Inherited from IUpdatable virtual void Update(double deltaTime); //Inherited from IDrawable virtual void Draw(BITMAP* dest); protected: private: }; I'm attempting to refactor it into a more manageable system. Mr. Nystrom uses the constructor to set the individual components; CHANGING these components at run-time is impossible. It's intended to be derived and be used in derivative classes or factory methods where their constructors do not change at run-time. i.e. his Bjorne object is just a call to a factory method with a specific call to the GameObject constructor. Is this a good idea? Should the object have a default constructor and setters to facilitate run-time changes or no default constructor without setters and instead use a factory method? Given: class Object { public: //...See below for constructor implementation concerns. Object(const Object& other); Object& operator=(const Object& rhs); virtual ~Object() =0; //See below for Setter concerns IUpdatable* GetUpdater(); IDrawable* GetRenderer(); protected: IUpdatable* _updater; IDrawable* _renderer; private: }; Should the components be read-only and passed in to the constructor via: class Object { public: //No default constructor. Object(IUpdatable* updater, IDrawable* renderer); //...remainder is same as above... }; or Should a default constructor be provided and then the components can be set at run-time? class Object { public: Object(); //... SetUpdater(IUpdater* updater); SetRenderer(IDrawable* renderer); //...remainder is same as above... }; or both? class Object { public: Object(); Object(IUpdater* updater, IDrawable* renderer); //... SetUpdater(IUpdater* updater); SetRenderer(IDrawable* renderer); //...remainder is same as above... };

    Read the article

  • Can I use a single DateTime field on the Entity Framework model side when the value is stored in a set of Int fields in the actual database?

    - by Ivan
    The actual table in the database has separate integer fields for storing year, month, day, hour and minute values (all in UTC) (seconds and milliseconds are irrelevant for my task and considered equal to zero). Needless to say it would be of great convenience to have just one field of DateTime type on the application side and hide all the conversion under the cover of the Entity Framework model code. Any directions on how to do that? I am not very experienced with Entity Framework yet.

    Read the article

  • Castle Windsor using wrong component to satisfy a dependency

    - by Neil Barnwell
    I have the following component mapping in Windsor xml: <component id="dataSession.DbConnection" service="System.Data.IDbConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="System.Data.SqlClient.SqlConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" lifestyle="custom" customLifestyleType="MyCompany.Castle.PerOperationLifestyle.PerOperationLifestyleManager, MyCompany.Castle"> <parameters> <connectionString>server=(local);database=MyCompany;trusted_connection=true;application name=OperationScopeTest;</connectionString> </parameters> </component> <component id="dataSession.DataContext" service="System.Data.Linq.DataContext, System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" type="MyCompany.BusinessLogic.MyCompanyDataContext, MyCompany.BusinessLogic" lifestyle="custom" customLifestyleType="MyCompany.Castle.PerOperationLifestyle.PerOperationLifestyleManager, MyCompany.Castle"> <parameters> <connection>${dataSession.DbConnection}</connection> </parameters> </component> However, when I ask the container for a DataContext, it actually uses the constructor requiring a connection string, despite the ${dataSession.DbConnection} being an IDbConnection. Why is this, and how to I make Windsor use the correct constructor?

    Read the article

  • VB6 App + .Net component working as compiled app but not in VB6 IDE

    - by Craig Johnston
    I have a VB6 App that uses a .Net component (via a .tlb reference in the VB6 app) which is working fine when executed as a compiled app, but it produces an error from the VB6 IDE a certain point when it is trying to use the .NET component. I should note that the error occurs when the .NET component is meant to be invoking a third party reporting component. What could the problem be? Could the VB6 IDE be looking in a different location for certain DLLs? The .tlb is in the same location as the application executable so I don't why there should be a problem. I need to have the application running in the IDE in order to debug and step through the code.

    Read the article

< Previous Page | 46 47 48 49 50 51 52 53 54 55 56 57  | Next Page >