Search Results

Search found 2412 results on 97 pages for 'relationship'.

Page 22/97 | < Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | 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

  • What is the relationship between recursion functions and memory stack?

    - by Eslam
    is there's a direct relationship between recursive functions and the memory stack, for more explanation consider that code: public static int triangle(int n) { System.out.println(“Entering: n = ” + n); if (n == 1) { System.out.println(“Returning 1”); return 1; } else { int temp = n + triangle(n - 1); System.out.println(“Returning“ + temp); return temp; } }? in this example where will the values 2,3,4,5 be stored until the function returns ? note that they will be returned in LIFO(LastInFirstOut) is these a special case of recursion that deals with the memory stack or they always goes together?

    Read the article

  • How to I create an HQL query to return objects in a many to many relationship?

    - by Dave
    Hi there. I have an application that includes 2 classes Club and Article. These are mapped in Hibernate as a many to many relationship. As a result, hibernate has created a table called CLUB_ARTICLE which it uses to manage the many to many relation ship. The CLUB and ARTILCE tables have no direct reference to each other and the mapping is only represented in the CLUB_ARTICLE table. I need to create an HQL query that returns a list of articles for a particlular club. So I need to supply the club id and get back a list of Article objects that belong to it. For some reason, I just can't work out how to do this. Any help would be very much appriciated! Thanks.

    Read the article

  • iPhones SDK: Setting a relationship property object using core data?

    - by Harkonian
    I'm using core data in my app. I have two entities that are related: EntityA and EntityB. EntityA has a property of type "relationship" with EntityB. In addition, both of these entities are defined classes (not the default NSManagedObject). I'm inserting a new object into my data like this: EntityA *newEntityA = [NSEntityDescription insertNewObjectForEntityForName:@"EntityA" inManagedObjectContext:self.managedObjectContext]; newEntityA.name = @"some name"; newEntityA.entityB.name = @"some other name"; The problem is entityB.name is null. Even if I add an NSLog() statement right after assigning the value, it is null. What is the proper way of setting my "name" property of EntityB when EntityB is a property of EntityA?

    Read the article

  • How to add a column via a query which counts the total rows with a specific criteria in a table with circular relationship in MS ACCESS 2007

    - by Xaqron
    I have a simple table "Employees" with this fields: ID, ParentID, Name ParentID is Nullable since an employee may have no Manager. This table has a one-to-many relationship with itself: ID --one--to--many--> ParentID Now I want a query which returns this columns: Name, Count of rows where their ParentID equals to the current row ID (the row is the manager of that rows) Sample Table: ID | ParentID | Name ====================== 1 | 0 | John ---------------------- 2 | 1 | Bob ---------------------- 3 | 1 | Alice ---------------------- 4 | 3 | Jack This way I can find an employee is the manager of how many other employees. The result should be something like this: Name | Count of Employees ========================== John | 2 -------------- Bob | 0 -------------- Alice | 1 -------------- Jack | 0 How can I achieve this in MS ACCESS 2007? * I have tried built-in query builder without any success.

    Read the article

  • Looking for an elegant way to store one-to-many relationship in coredata when order is important

    - by Eric Schweichler
    I've been trying to come up with a way to solve my problem, but every solution I can think of is messy and makes me want to retch. I have a one-to-many relationship, consisting of a Team object that can have many Member objects. When I built my data model using Xcode, I was given the default NSSet in which to store the member objects, Unfortunately Sets are not ordered and I need to preserve the order of the Member objects and I need to know if there are empty spaces between Members. I thought of Using an NSArray in place of the NSSet and creating a dummy Member object in my data store that I could use to mark vacant a spot between to Member objects, but that solution really feels like too much of a hack to me. Since I'll always have to filter out this dummy Member from any queries. An NSDictionary would be perfect as I could store the Member object references and their positions as Object-Key pairs, (taking care of both order and vacancies) but apparently CoreData does not support NSDictionary. Has anyone had a similar need, and devised a simple solution?

    Read the article

  • Get the ID of a Child in a cascade="all" relationship, while adding it to a collection, in Hibernate

    - by Marco
    Hi, i have two Entities, "Parent" and "Child", that are linked through a bidirectional one-to-many relationship with the cascade attribute set to "all". When adding a Child object to the Parent children collection using the code below, i can't get the ID of the persisted child until i commit the transaction: Parent p = (Parent) session.load(Parent.class, pid); Child c = new Child(); p.addChild(c); // "c" hasn't an ID (is always zero) However, when i persist a child entity by explicitly calling the session.save() method, the ID is created and set immediately, even if the transaction hasn't been committed: Child c = new Child(); session.save(c); // "c" has an ID Is there a way to get the ID of the child entity immediately without calling the session.save() method? Thanks

    Read the article

  • How to set up a has-many relationship in Cocoa?

    - by SphereCat1
    I'm building a (very) simple FTP app in Cocoa, and I need to store information on the different types of servers that are supported. So, I've created a ServerType class, which stores all of the relevant information about a single type of server. I then have a ServerTypes class which is designed to manage all of the ServerType classes that are created. My question is how to set up the relationship between the two objects. Is there a preferred method to do so? Also, since Objective-C doesn't support non-instance classes, where should I create an instance of ServerTypes that will have to be used throughout the entire program? Or is there a better way to do that? I need it to be KVC compliant so That I can bind one of the ServerType properties to an NSPopupBox. Sorry about the large volume of questions, I'm fairly new to Cocoa and Objective-C. If you need to see code, just ask and I'll be happy to add some. :) SphereCat1

    Read the article

  • Why wouldn't I be able to establish a trust relationship for a SSL/TLS channel?

    - by Abe Miessler
    I have a piece of .NET code that is erroring out when it makes a call to HTTPWebRequest.GetRequestStream. Here is the error message: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. I've read a few things that suggest that I might need a certificate on the machine running the code, but i'm not sure if that's true or how to do it. If I need to get a certificate, how do I do it? Code: var request = (HttpWebRequest)HttpWebRequest.Create(requestUrl); //my url request.Method = StringUtilities.ConvertToString(httpMethod); // Set the http method GET, POST, etc. if (postData != null) { request.ContentLength = postData.Length; request.ContentType = contentType; using (var dataStream = request.GetRequestStream()) { dataStream.Write(postData, 0, postData.Length); } }

    Read the article

  • In a client-server relationship, should the server always rethrow the exception to the client?

    - by dotnetdev
    I have a set of web services (the server), and an app which consumes this (client). In this sort of relationship, should the server always throw exceptions (ie in the throw block, rethrow the caught exception), and the client catch this. Exceptions which the server can handle, it will deal with and not rethrow, but everything else will be thrown to the calling layer for further action (the consuming app can raise a msg box or whatever). Is this a good example of an exception that can be dealt with: A file cannot be written because the directory requires special privileges, so if this raises an exception, the file is written somewhere which does not require admin rights. Thanks

    Read the article

  • How do I query through a many-to-many relationship using NHibernate Criteria and Lambda Extensions?

    - by Brian Kendig
    In my database I have a Person table and an Event table (parties, meetings, &c.). This many-to-many relationship is represented through an Invitation table. Each Person can have many Invitations. Each Event can also have many Invitations. If I want a list of Events to which a Person is invited, I can use this HQL query: IQuery query = Session.CreateQuery("SELECT i.Event from Invitation i where i.Person = :p"); query.SetParameter("p", person); return query.List<Person>(); How would I write this query with NHibernate criteria and Lambda Extensions?

    Read the article

  • How to insert an n:m-relationship with technical primary keys generated by a sequence?

    - by bitschnau
    Let's say I have two tables with several fields and in every table there is a primary key which is a technical id generated by a database sequence: table1 table2 ------------- ------------- field11 <pk> field21 <pk> field12 field22 field11 and field21 are generated by sequences. Also there is a n:m-relationship between table1 und table2, designed in table3: table3 ------------- field11 <fk> field21 <fk> The ids in table1 und table2 are generated during the insert statement: INSERT INTO table1 VALUES (table1_seq1.NEXTVAL, ... INSERT INTO table2 VALUES (table2_seq1.NEXTVAL, ... Therefore I don't know the primary key of the added row in the data-access-layer of my program, because the generation of the pk happens completely in the database. What's the best practice to update table3 now? How can I gain access to the primary key of the rows I just inserted?

    Read the article

  • What's the relationship between the Intel Atom Developer Program and the MeeGo operating system?

    - by Arne Evertsson
    I'm trying to understand the relationship between the Intel Atom Developer Program (IADP) and the new OS called MeeGo. IADP let's me create applications that run on both MeeGo as well as Windows devices, as long as the device is based on the Atom processor. The IADP apps are published in an app store called AppUp, which is very much like the Apple App Store. The MeeGo operating system merges Intel's Moblin and Nokia's Maemo into one OS. The purpose seems to be to make it possible to develop software that will run on Intel powered devices, Nokia-made devices, as well devices from other companies. Nokia has its Ovi Store that will support MeeGo apps. With its OS independent runtime, the question is what an IADP app really is? Is an IADP app a beast of its own, or is it just a MeeGo app that has been restricted to run only on Atom powered devices? Will it be possible to recompile my IADP app to run on all MeeGo devices? Sold in Ovi Store? Intel and Nokia have me really confused. Where should I go as a developer?

    Read the article

  • Mapping composite foreign keys in a many-many relationship, with overlapping components.

    - by Kirk Broadhurst
    I have a Page table and a View table. There is a many-many relationship between these two via a PageView table. Unfortunately all of these tables need to have composite keys (for business reasons). Page has a primary key of (PageCode, Version), View has a primary key of (ViewCode, Version). PageView obviously enough has PageCode, ViewCode, and Version. The FK to Page is (PageCode, Version) and the FK to View is (ViewCode, Version) Makes sense and works, but when I try to map this in Entity framework I get Error 3021: Problem in mapping fragments...: Each of the following columns in table PageView is mapped to multiple conceptual side properties: PageView.Version is mapped to (PageView_Association.View.Version, PageView_Association.Page.Version) So clearly enough, EF is having a complain about the Version column being a common component of the two foreign keys. Obviously I could create a PageVersion and ViewVersion column in the join table, but that kind of defeats the point of the constraint, i.e. the Page and View must have the same Version value. Has anyone encountered this, and is there anything I can do get around it? Thanks!

    Read the article

  • why when I delete a parent on a one to many relationship on grails the beforeInsert event is called

    - by nico
    hello, I have a one to many relationship and when I try to delete a parent that haves more than one child the berforeInsert event gets called on the frst child. I have some code in this event that I mean to call before inserting a child, not when i'm deleting the parent! any ideas on what might be wrong? the entities: class MenuItem { static constraints = { name(blank:false,maxSize:200) category() subCategory(nullable:true, validator:{ val, obj -> if(val == null){ return true }else{ return obj.category.subCategories.contains(val)? true : ['invalid.category.no.subcategory'] } }) price(nullable:true) servedAtSantaMonica() servedAtWestHollywood() highLight() servedAllDay() dateCreated(display:false) lastUpdated(display:false) } static mapping = { extras lazy:false } static belongsTo = [category:MenuCategory,subCategory:MenuSubCategory] static hasMany = [extras:MenuItemExtra] static searchable = { extras component: true } String name BigDecimal price Boolean highLight = false Boolean servedAtSantaMonica = false Boolean servedAtWestHollywood = false Boolean servedAllDay = false Date dateCreated Date lastUpdated int displayPosition void moveUpDisplayPos(){ def oldDisplayPos = MenuItem.get(id).displayPosition if(oldDisplayPos == 0){ return }else{ def previousItem = MenuItem.findByCategoryAndDisplayPosition(category,oldDisplayPos - 1) previousItem.displayPosition += 1 this.displayPosition = oldDisplayPos - 1 this.save(flush:true) previousItem.save(flush:true) } } void moveDownDisplayPos(){ def oldDisplayPos = MenuItem.get(id).displayPosition if(oldDisplayPos == MenuItem.countByCategory(category) - 1){ return }else{ def nextItem = MenuItem.findByCategoryAndDisplayPosition(category,oldDisplayPos + 1) nextItem.displayPosition -= 1 this.displayPosition = oldDisplayPos + 1 this.save(flush:true) nextItem.save(flush:true) } } String toString(){ name } def beforeInsert = { displayPosition = MenuItem.countByCategory(category) } def afterDelete = { def otherItems = MenuItem.findAllByCategoryAndDisplayPositionGreaterThan(category,displayPosition) otherItems.each{ it.displayPosition -= 1 it.save() } } } class MenuItemExtra { static constraints = { extraOption(blank:false, maxSize:200) extraOptionPrice(nullable:true) } static searchable = true static belongsTo = [menuItem:MenuItem] BigDecimal extraOptionPrice String extraOption int displayPosition void moveUpDisplayPos(){ def oldDisplayPos = MenuItemExtra.get(id).displayPosition if(oldDisplayPos == 0){ return }else{ def previousExtra = MenuItemExtra.findByMenuItemAndDisplayPosition(menuItem,oldDisplayPos - 1) previousExtra.displayPosition += 1 this.displayPosition = oldDisplayPos - 1 this.save(flush:true) previousExtra.save(flush:true) } } void moveDownDisplayPos(){ def oldDisplayPos = MenuItemExtra.get(id).displayPosition if(oldDisplayPos == MenuItemExtra.countByMenuItem(menuItem) - 1){ return }else{ def nextExtra = MenuItemExtra.findByMenuItemAndDisplayPosition(menuItem,oldDisplayPos + 1) nextExtra.displayPosition -= 1 this.displayPosition = oldDisplayPos + 1 this.save(flush:true) nextExtra.save(flush:true) } } String toString(){ extraOption } def beforeInsert = { if(menuItem){ displayPosition = MenuItemExtra.countByMenuItem(menuItem) } } def afterDelete = { def otherExtras = MenuItemExtra.findAllByMenuItemAndDisplayPositionGreaterThan(menuItem,displayPosition) otherExtras.each{ it.displayPosition -= 1 it.save() } } }

    Read the article

  • Fluent NHibernate: Example of a one-to-many relationship on an abstract class of a table-per-subclas

    - by BigTommy79
    Hi All, I've been trying for ages to find an example (because I can't get it to work myself) of the correct mapping for a one-to-many relationship on an abstract class of a table-per-subclass implementation, in fluent nHibernate. An example below: I'm looking to map the list of Fines on the Debt abstract base class to the Fine class. if anyone knows of any tutorial or example they've come across before please let me know. Thanks, Tim public abstract class Entity { public int Id { get; set; } } public abstract class Debt : Entity { public decimal Balance { get; set; } public IList<Fine> Fines { get; set; } public Debt() { Fines = new List<Fine>(); } } public class CarLoan : Debt { } public class CreditCard : Debt { } public class LoanApplication : Entity { public IList<Debt> ExistingDebts { get; set; } public LoanApplication() { ExistingDebts = new List<Debt>(); } } public class Fine { public Int64 Cash { get; set; } }

    Read the article

  • Having to insert a record, then update the same record warrants 1:1 relationship design?

    - by dianovich
    Let's say an Order has many Line items and we're storing the total cost of an order (based on the sum of prices on order lines) in the orders table. -------------- orders -------------- id ref total_cost -------------- -------------- lines -------------- id order_id price -------------- In a simple application, the order and line are created during the same step of the checkout process. So this means INSERT INTO orders .... -- Get ID of inserted order record INSERT into lines VALUES(null, order_id, ...), ... where we get the order ID after creating the order record. The problem I'm having is trying to figure out the best way to store the total cost of an order. I don't want to have to create an order create lines on an order calculate cost on order based on lines then update record created in 1. in orders table This would mean a nullable total_cost field on orders for starters... My solution thus far is to have an order_totals table with a 1:1 relationship to the orders table. But I think it's redundant. Ideally, since everything required to calculate total costs (lines on an order) is in the database, I would work out the value every time I need it, but this is very expensive. What are your thoughts?

    Read the article

  • How do I specify the foreign key on a many-to-one relationship when is not a property on the object

    - by jjujuma
    I'm trying to map a many-to-one relationship from MarketMenuBranch to Market. My classes look like: public class Market implements Serializable { private int id; private String name; private List<MarketMenuBranch> marketMenuBranches; // accessors / mutators etc... public class MarketMenuBranch implements Serializable { private MarketMenuBranchId id; private String name; // accessors / mutators etc... public class MarketMenuBranchId implements Serializable { private int marketId; private int sequence; // accessors / mutators etc... But I don't know what I can put for the property name (where I have ???? below). I really want to put id.marketId but that seems to be wrong. <class name="MarketMenuBranch" table="MARKET_MENU_BRANCH"> <composite-id name="id" class="MarketMenuBranchId"> <key-property name="marketId"/> <key-property name="sequence"/> </composite-id> <property name="name"/> <many-to-one name="????????"/> </class> How can I do this?

    Read the article

  • Logic in the db for maintaining a points system relationship?

    - by MarcusBooster
    I'm making a little web based game and need to determine where to put logic that checks the integrity of some underlying data in the sql database. Each user keeps track of points assigned to him, and points are awarded by various tasks. I keep a record of each task transaction to make sure they're not repeated, and to keep track of the value of the task at the time of completion, since an individual award level my fluctuate over time. My schema looks like this so far: create table player ( player_ID serial primary key, player_Points int not null default 0 ); create table task ( task_ID serial primary key, task_PointsAwarded int not null ); create table task_list ( player_ID int references player(player_ID), task_ID int references task(task_ID), when_completed timestamp default current_timestamp, point_value int not null, --not fk because task value may change later constraint pk_player_task_id primary key (player_ID, task_ID) ); So, the player.player_Points should be the total of all his cumulative task points in the task_list. Now where do I put the logic to enforce this? Should I do away with player.player_Points altogether and do queries every time I want to know the total score? Which seems wasteful since I'll be doing that query a lot over the course of a game. Or, put a trigger in the task_list that automatically updates the player.player_Points? Is that too much logic to have in the database and should just maintain this relationship in the application? Thanks.

    Read the article

  • Rails - HABTM Relationship -- How Can I Find A Record Based On An Attribute Of The Associated Model

    - by ChrisWesAllen
    I have setup this HABTM relationship in the past and its worked before....Now it isnt and I'm at my wits end trying to figure out whats wrong. I've looking through the rails guides all day and cant seem to figure out what I'm doing wrong, so help would really be appreciated. I have 2 models connected through a join model and I'm trying to find records based an attribute of the associated model. Event.rb has_and_belongs_to_many :interests Interest.rb has_and_belongs_to_many :events and a join table migration that was created like create_table 'events_interests', :id => false do |t| t.column :event_id, :integer t.column :interest_id, :integer end I tried @events = Event.all(:include => :interest, :conditions => [" interest.id = ?", 4 ] ) But got the error "Association named 'interest' was not found; perhaps you misspelled it?"... which I didnt of course I tried @events = Event.interests.find(:all, :conditions => [" interest.id = ?", 4 ] ) but got the error "undefined method `interests' for #Class:0x4383348" How can I find the Events that have an interest id of 4....I'm definitely going bald from this lol

    Read the article

  • Can you configure multiple KMS hosts in a primary / secondary relationship?

    - by Mark Hall
    We have two datacenters in our environment: primary and DR. I need to deploy a KMS service, and to be proactive, I would like to have a host in both datacenters. From what I have read, you can have up to 6 hosts without calling Microsoft, and it appears that what will happen is that a SRV record for each host will be placed in DNS. The client will query for those SRV records and randomly choose a host for the initial activation and will use that same server for all renewals. The server can be changed manually through a script and will automatically change if the initial server is unavailable when activating or renewing. My question is has anyone found a way to designate one server as the primary KMS host and designate the other as failover only? The reason I ask is that it is preferred that the client communicate with the primary datacenter during normal operations and only talk to the DR datacenter when needed because the bandwidth between the offices and the DR datacenter is limited compared to the primary. I am sure that this has been done before but I can not find it MSFT's documentation. Thanks, Mark

    Read the article

  • The security database on the server does not have a computer account for this workstation trust relationship

    - by alex
    I have a Server 2008 machine called OTTO I recently, by mistake, booted up an old machine, also called OTTO (the hardware was unstable, so the new one was set up to take it's place) I shut down the old machine, turned it off, and recycled it (it won't ever be back on) Now, whenever i try to log in to the real OTTO with the domain account (mydomain\Administrator) i get the following error: The security database on the server does not have a computer account for this workstation What can I do to fix this? It doesn't appear in active directory any more I've added it, but I'm guessing this had no effect, due to a different SID I can log in as the local administrator however

    Read the article

  • Relationships in a Chen ERD

    - by Nibroc A Rehpotsirhc
    I am working on a Chen ERD to model our organizations merchandise. Our central entity is a Style. We have supplemental entities of Color and Season. I am defining our assortment as the relationship between these three entities, and this relationship itself will have attributes and is defined by the three entities which participate in the mandatory relationship. The rules are; Many Styles can be offered in a Season, and a Style can be offered in many Seasons. Within a Season, a Style can be offered in Many Colors. I then have 2 other entities, one of which I believe is a weak entity, Climate, and the other may be weak, but I am not sure, this being Transaction Channel. I am thinking of these as relationships off of a relationship? Meaning, for a given Style/Color combination offered in a Season, it can be available through 1 or more Transaction Channels. Additionally, within a season, a given Style/Color combination can be intended for 1 or more Climates. Is it valid to have relationships off of relationships? Or does this requirement dictate that I should think of this Style/Color/Season relationship as an entity itself, and define the relationships to Climate and Transaction Channel off of this entity?

    Read the article

  • Is a many-to-many relationship with extra fields the right tool for my job?

    - by whichhand
    Previously had a go at asking a more specific version of this question, but had trouble articulating what my question was. On reflection that made me doubt if my chosen solution was correct for the problem, so this time I will explain the problem and ask if a) I am on the right track and b) if there is a way around my current brick wall. I am currently building a web interface to enable an existing database to be interrogated by (a small number of) users. Sticking with the analogy from the docs, I have models that look something like this: class Musician(models.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) dob = models.DateField() class Album(models.Model): artist = models.ForeignKey(Musician) name = models.CharField(max_length=100) class Instrument(models.Model): artist = models.ForeignKey(Musician) name = models.CharField(max_length=100) Where I have one central table (Musician) and several tables of associated data that are related by either ForeignKey or OneToOneFields. Users interact with the database by creating filtering criteria to select a subset of Musicians based on data the data on the main or related tables. Likewise, the users can then select what piece of data is used to rank results that are presented to them. The results are then viewed initially as a 2 dimensional table with a single row per Musician with selected data fields (or aggregates) in each column. To give you some idea of scale, the database has ~5,000 Musicians with around 20 fields of related data. Up to here is fine and I have a working implementation. However, it is important that I have the ability for a given user to upload there own annotation data sets (more than one) and then filter and order on these in the same way they can with the existing data. The way I had tried to do this was to add the models: class UserDataSets(models.Model): user = models.ForeignKey(User) name = models.CharField(max_length=100) description = models.CharField(max_length=64) results = models.ManyToManyField(Musician, through='UserData') class UserData(models.Model): artist = models.ForeignKey(Musician) dataset = models.ForeignKey(UserDataSets) score = models.IntegerField() class Meta: unique_together = (("artist", "dataset"),) I have a simple upload mechanism enabling users to upload a data set file that consists of 1 to 1 relationship between a Musician and their "score". Within a given user dataset each artist will be unique, but different datasets are independent from each other and will often contain entries for the same musician. This worked fine for displaying the data, starting from a given artist I can do something like this: artist = Musician.objects.get(pk=1) dataset = UserDataSets.objects.get(pk=5) print artist.userdata_set.get(dataset=dataset.pk) However, this approach fell over when I came to implement the filtering and ordering of query set of musicians based on the data contained in a single user data set. For example, I could easily order the query set based on all of the data in the UserData table like this: artists = Musician.objects.all().order_by(userdata__score) But that does not help me order by the results of a given single user dataset. Likewise I need to be able to filter the query set based on the "scores" from different user data sets (eg find all musicians with a score 5 in dataset1 and < 2 in dataset2). Is there a way of doing this, or am I going about the whole thing wrong?

    Read the article

  • How to Add, Edit and Display one to many relationship entities in ASP.Net MVC 2?

    - by Picflight
    I am looking for best practices conforming to the MVC design pattern. My Entities have the following relationship. tblPortal PortalId PrortalName tblPortalAlias AliasId PortalId HttpAlias Each Portal can have many PortalAlias. I want to Add a New Portal and then Add the associated PortalAlias. I am confused on how I should structure the Views and how I should present the Views to the user. I am looking for some sample code on how to accomplish this. My thoughts are first present the Portal View, let the user add the Portal. Then click the Edit link on the Portal List View and on the Portal Edit View let them Add the PortalAlias. If so, what should the Edit View look like? So far I have: Edit <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MyProject.Mvc.Models.PortalFormViewModel>" %> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> Edit </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2>Edit</h2> <% Html.RenderPartial("PortalForm", Model); %> <div> <%= Html.ActionLink("Back to List", "Index") %> </div> </asp:Content> PortalForm <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MyProject.Mvc.Models.PortalFormViewModel>" %> <%= Html.ValidationSummary("Please correct the errors and try again.") %> <% using (Html.BeginForm()) {%> <%= Html.ValidationSummary(true) %> <fieldset> <legend>Fields</legend> <div class="editor-label"> <%= Html.LabelFor(model => model.Portal.PortalId) %> </div> <div class="editor-field"> <%= Html.TextBoxFor(model => model.Portal.PortalId) %> <%= Html.ValidationMessageFor(model => model.Portal.PortalId) %> </div> <div class="editor-label"> <%= Html.LabelFor(model => model.Portal.PortalName) %> </div> <div class="editor-field"> <%= Html.TextBoxFor(model => model.Portal.PortalName) %> <%= Html.ValidationMessageFor(model => model.Portal.PortalName) %> </div> <p> <input type="submit" value="Save" /> </p> </fieldset> <% } %> Alias<br /><%-- This display is for debug --%> <% foreach (var item in Model.PortalAlias) { %> <%= item.HTTPAlias %><br /> <% } %> PortalFormViewModel public class PortalFormViewModel { public Portal Portal { get; private set; } public IEnumerable<PortalAlias> PortalAlias { get; private set; } public PortalFormViewModel() { Portal = new Portal(); } public PortalFormViewModel(Portal portal) { Portal = portal; PortalAlias = portal.PortalAlias; } }

    Read the article

< Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >