Search Results

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

Page 105/397 | < Previous Page | 101 102 103 104 105 106 107 108 109 110 111 112  | Next Page >

  • The Columns in table <table> do not match an existing primary key or unique constraint

    - by Sven
    I have 2 tables, Stores - storeId (int) and year (int(4)) both Primary Keys. fruit - fruitId - Primary Key and storeId. I need to create 1 to many relationship between the Store and Fruit (Foreign Key held within Fruit) how ever I always get shown the error - The Columns in table <table> do not match an existing primary key or unique constraint. The type's are both int and named the same. Any help would be appreciate in advance, many thanks.

    Read the article

  • Succinct But Complete Example of WPF App?

    - by Eric J.
    Is there a succinct but complete example project or tutorial that brings together the pieces of the Microsoft stack for a complete application? WPF MVVM Business Objects EF Database I find plenty for WPF and plenty for EF, but am having trouble fully understanding how the EF generated classes relate to business objects, and how those business objects in turn fit into the MVVM pattern.

    Read the article

  • Need help converting SQL to EF4 please

    - by Ken Eldridge
    I need help converting this SQL statement, into EF4: Select Posts.PostID, Post, Comment from Posts left join Comments on posts.PostID = Comments.PostID Where CommentID not in ( Select PostID from Votes where VoteTypeID = 4 --4 = flagged comment type ) In my database, the Votes table stores either the PostID of reported posts, or CommentID of reported comments in the column Votes.PostID Thanks in advance!

    Read the article

  • Linq - How to collect Anonymous Type as Result for a Function

    - by GibboK
    I use c# 4 asp.net and EF 4. I'm precompiling a query, the result should be a collection of Anonymous Type. At the moment I use this code. public static readonly Func<CmsConnectionStringEntityDataModel, string, dynamic> queryContentsList = CompiledQuery.Compile<CmsConnectionStringEntityDataModel, string, dynamic> ( (ctx, TypeContent) => ctx.CmsContents.Where(c => c.TypeContent == TypeContent & c.IsPublished == true & c.IsDeleted == false) .Select(cnt => new { cnt.Title, cnt.TitleUrl, cnt.ContentId, cnt.TypeContent, cnt.Summary } ) .OrderByDescending(c => c.ContentId)); I suspect the RETURN for the FUNCTION Dynamic does not work properly and I get this error Sequence contains more than one element enter code here. I suppose I need to return for my function a Collection of Anonymous Types... Do you have any idea how to do it? What I'm doing wrong? Please post a sample of code thanks! Update: public class ConcTypeContents { public string Title { get; set; } public string TitleUrl { get; set; } public int ContentId { get; set; } public string TypeContent { get; set; } public string Summary { get; set; } } public static readonly Func<CmsConnectionStringEntityDataModel, string, ConcTypeContents> queryContentsList = CompiledQuery.Compile<CmsConnectionStringEntityDataModel, string, ConcTypeContents>( (ctx, TypeContent) => ctx.CmsContents.Where(c => c.TypeContent == TypeContent & c.IsPublished == true & c.IsDeleted == false) .Select(cnt => new ConcTypeContents { cnt.Title, cnt.TitleUrl, cnt.ContentId, cnt.TypeContent, cnt.Summary }).OrderByDescending(c => c.ContentId));

    Read the article

  • Filter list as a parameter in a compiled query

    - by JK
    I have the following compiled query that I want to return a list of "groups" that don't have a "GroupID" that's contained in a filtered list: CompiledQuery.Compile(ConfigEntities contexty, List list) = from c in context.Groups where (!csList.Contains(c.GroupID)) select c).ToList() However I'm getting the following run-time error: The specified parameter 'categories' of type 'System.Collections.Generic.List`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c261364e126]]' is not valid. Only scalar parameters (such as Int32, Decimal, and Guid) are supported. Any ideas?

    Read the article

  • Spring-Hibernate: How to submit a for when the object has one-to-many relations?

    - by Czar
    Hi, I have a form changeed the properties of my object CUSTOMER. Each customer has related ORDERS. The ORDER's table has a column customer_id which is used for the mapping. All works so far, I can read customers without any problem. When I now e.g. change the name of the CUSTOMER in the form (which does NOT show the orders), after saving the name is updated, but all relations in the ORDERS table are set to NULL (the customer_id for the items is set to NULL. How can I keep the relationship working? THX

    Read the article

  • convert a sql statement to class?

    - by walter
    Is there a tool or code to convert a sql statement to class? Something like: Dim sqlText = "SELECT CustomerID, Name, Address, City FROM dbo.Customer WHERE CustomerID = 1" Dim obj As New ***SqlStatementTool***(sqlText) obj.GetTables() 'Will Return Tables in sqlText obj.GetWheres() 'Will Return conditions in sqltext obj.GetParameters() 'will return parameters in sqltext

    Read the article

  • EntityFramework gives IDisposable error

    - by Snoop Dogg
    I use EF for the back-end DataLayer in my asp.net websites. I create a class library and add the Model in it, reference it and use it from the ASP.NET Website. But this time, I generated the model from database but it seems does not implement IDisposable, and the methods I used to see are not there. DeleteObject , SaveChanges etc. There are only Two tables in the DB and the Model was generated with only the TableSets and two methods AddToTableSet ... Had anybody encountered such a problem?

    Read the article

  • EntityManager does not update on flush()

    - by Sara
    Java EJB's EntityManager does not update data from a Consumer. A Consumer logs into a shop, buys some stuff and wants to look at his shopping-history. Everything is displayed but his last purchase. If he logs out and in, it shows. I have used JPA to persist buys/purchases (that are mapped to the Consumer)to DB. It seems like purchases from this session can't be detected. Code: public Buys buyItem(Consumer c, int amount) { Buys b = new Buys(); b.setConsumerId(c); b.setContent("DVD"); b.setPrice(amount); em.persist(b); em.flush(); return b; } public Collection getAllBuysFromUser(Consumer consumer) { Collection collection = consumer.getBuysCollection(); return collection; } Help!? Flush does not do the trick...

    Read the article

  • Enity framework not loading relationship even when using include

    - by dilbert789
    I have this code: Category selectedCategory = (from c in DB.Category.Include("SubCategory") join a in DB.Accessory on c.AccCatUID equals a.Category.AccCatUID where a.AccUID == currentAccessory.AccUID select c).FirstOrDefault(); It works fine, selectedCategory gets populated as expected. BUT selectedCategory has a child table 'SubCategory' which does not get loaded even though there is the include there. It is not loaded until I do this: selectedCategory.SubCategory.Load(); Why do I have to call load explicitly in order to load the child table?

    Read the article

  • How to design this simple database?

    - by Vafello
    I have 2 tables - one storing user information (id, username, password) and the second one storing information about events (id, name, description, date, username(represents the user who created the event)). I would like to implement 'favourite events' functionality. This would allow the user to store his favourite events and later display them in a list. I am not sure how to implement this in terms of design. I need a simple solution. Something like storing the IDs of favourite events in a field in the user table. I am using mysql and php. Can anyone point me to the right direction?

    Read the article

  • Arranging VS2008 generated LinqToSql/EntityFramework data models/contexts in assemblies.

    - by JMSA
    What pattern should I use for data-access in case of VS2008 generated L2s or EF DataModels? Repository-pattern or what? As we know VS2008 generates Data-Models and DataContexts/ObjectContexts in the same file, then, how should I arrange my VS2008 assemblies in my VS2008 solution to achieve a layered design? If I use repository pattern, how should I arrange my assemblies in the VS2008 solution (as Data-Models and Data/Object-Contexts are stored in the same file...)? Any web/example link would be appreciated.

    Read the article

  • How do I make this Query against EF Efficient?

    - by dudeNumber4
    Using EF4. Assume I have this: IQueryable<ParentEntity> qry = myRepository.GetParentEntities(); Int32 n = 1; What I want to do is this, but EF can't compare against null. qry.Where( parent => parent.Children.Where( child => child.IntCol == n ) != null ) What works is this, but the SQL it produces (as you would imagine) is pretty inefficient: qry.Where( parent => parent.Children.Where( child => child.IntCol == n ).FirstOrDefault().IntCol == n ) How can I do something like the first comparison to null that won't be generating nested queries and so forth?

    Read the article

  • update table with information from IDirectory

    - by sue
    I have a table with 4 columns, LoginID, LastName, FirstName, Email. The data for LoginID was populated from an other table. I have to write a small routine to update this table, by sending in the LoginID and with help of IDirectory routines, get the Lastname, firstname and email. This is what i'm attempting to do, but getting confused with the right syntax. using (TSADRequestEntities context = UnityHelper.Resolve()) { var fpvalues = context.FOCALPOINTs.ToList(); foreach (var item in fpvalues) { IEnumerable<UserInfo> query = UnityHelper.Resolve<IUserDirectory>().Search(item.LoginID); //Here, FocalPoint is the table that has the loginID and the other fields //I need to update. the query shld now hv info on lastname etc..how do I //retrieve that value and update the table? } }

    Read the article

  • Return nullable datetime from scalar, stored procedure

    - by molgan
    Hello I have a function that returns a date from a stored procedure, and it all works great til the value is NULL, how can I fix this so it works with null aswell? public DateTime? GetSomteDate(int SomeID) { DateTime? LimitDate= null; if (_entities.Connection.State == System.Data.ConnectionState.Closed) _entities.Connection.Open(); using (EntityCommand c = new EntityCommand("MyEntities.GetSomeDate", (EntityConnection)this._entities.Connection)) { c.CommandType = System.Data.CommandType.StoredProcedure; EntityParameter paramSomeID = new EntityParameter("SomeID", System.Data.DbType.Int32); paramSomeID.Direction = System.Data.ParameterDirection.Input; paramSomeID.Value = SomeID; c.Parameters.Add(paramSomeID); var x = c.ExecuteScalar(); if (x != null) LimitDate = (DateTime)x; return LimitDate.Value; }; }

    Read the article

  • Problem with connectionstring and entityframework

    - by Masna
    Hello, I have a database (sql 2008 mdf file), a class library project with an edmx file, created with the wizard. So the connection string is also made by the wizard. This project is on a teamfoundation server. I can use all the wizard made objects when coding. But when i run the program and I try to make an entityContainerName, the program crashes and gives this error: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid. on this line: public TestEntities() : base("name=TestEntities", "TestEntities") How can I solve this problem or what am I doing wrong?

    Read the article

  • ASP.net MVC3 entities, don't know how to count

    - by Spedax
    I have 2 tables, 1 with countries, 1 with states. The states table has a column with Population. I'm using entities and I have created a List of states for the countries public class TblCountries { //Entities for my table country ... public List<tblStates> States { get; set; } } So now I can for example List all the states that belong to a country. Now what I want to do is count the population, so I can show the population that of an entire country. I tried using in my view @foreach (var item in Model.Countries) { @Html.DisplayFor(modelItem => item.States.Count<population>) } But this doesn't work, anyone know how to do this? Thanks in advanced!

    Read the article

  • EF recovery from invalidoperationexception caused by server being down

    - by Jonn
    I had a windows service relying on EF, and it was running fine until the server went down. The problem was after the server went up again, it didn't fix itself and still threw the error: INTERNAL ERROR: Execution of the command requires an open and available connection. The connection's current state is broken. Not being very proficient in EF I'm not aware of how I could recover from such a scenario, and why it occurred in the first place? Anyone had this happen before?

    Read the article

  • Custom OData operation / customize EF model to hide join table in many-to-many relationship

    - by AC
    I've got a data model that has two tables with a join table for a many to many relationship & creating an OData service to expose the data for CRUD ops in a Silverlight app. What I'd like to do is abstract the join table from the service. I'm not sure if the best way to do this would be in the model (using EF in .NET3.5SP1) or if I should do it with a custom service operation. If I do it in the EF model (not sure how I'd do this), then the OOTB WCF Data Service stuff would make it easy to say [..]/Courses(1)/Modules ... otherwise I'd have to create a custom operation to do this. Is it possible to do this in the EF model and if so, how does that work?

    Read the article

  • LinkDemand error on webserver when using TrackSource

    - by robertpnl
    Hi, On a webserver (shared hosting provider) I published a website with a ADO.Net Framework model in use with MySql Connector 6.3.1. When I request a page, a Security Exception will be happen with this error messages: "LinkDemand The type of the first permission that failed was: System.Security.Permissions.SecurityPermission The Zone of the assembly that failed was: MyComputer ". This exception raised when code collect the listeners of a tracksource: public class MySqlTrace { private static TraceSource source = new TraceSource("mysql"); static MySqlTrace() { foreach (TraceListener listener in source.Listeners) // <-- Exception throw here { // ... } } } The web.config doesn't have any trace data or system.diagnostics. My question is, why will a get a LinkDemand security exception during collecting the source listeners. What can maybe be wrong in here?

    Read the article

  • Circular database relationships. Good, Bad, Exceptions?

    - by jim
    I have been putting off developing this part of my app for sometime purely because I want to do this in a circular way but get the feeling its a bad idea from what I remember my lecturers telling me back in school. I have a design for an order system, ignoring the everything that doesn't pertain to this example I'm left with: CreditCard Customer Order I want it so that, Customers can have credit cards (0-n) Customers have orders (1-n) Orders have one customer(1-1) Orders have one credit card(1-1) Credit cards can have one customer(1-1) (unique ids so we can ignore uniqueness of cc number, husband/wife may share cc instances ect) Basically the last part is where the issue shows up, sometimes credit cards are declined and they wish to use a different one, this needs to update which their 'current' card is but this can only change the current card used for that order, not the other orders the customer may have on disk. Effectively this creates a circular design between the three tables. Possible solutions: Either Create the circular design, give references: cc ref to order, customer ref to cc customer ref to order or customer ref to cc customer ref to order create new table that references all three table ids and put unique on the order so that only one cc may be current to that order at any time Essentially both model the same design but translate differently, I am liking the latter option best at this point in time because it seems less circular and more central. (If that even makes sense) My questions are, What if any are the pros and cons of each? What is the pitfalls of circular relationships/dependancies? Is this a valid exception to the rule? Is there any reason I should pick the former over the latter? Thanks and let me know if there is anything you need clarified/explained. --Update/Edit-- I have noticed an error in the requirements I stated. Basically dropped the ball when trying to simplify things for SO. There is another table there for Payments which adds another layer. The catch, Orders can have multiple payments, with the possibility of using different credit cards. (if you really want to know even other forms of payment). Stating this here because I think the underlying issue is still the same and this only really adds another layer of complexity.

    Read the article

< Previous Page | 101 102 103 104 105 106 107 108 109 110 111 112  | Next Page >