Search Results

Search found 578 results on 24 pages for 'relations'.

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

  • Django User M2M relationship

    - by Antonio
    When trying to syncdb with the following models: class Contact(models.Model): user_from = models.ForeignKey(User,related_name='from_user') user_to = models.ForeignKey(User, related_name='to_user') class Meta: unique_together = (('user_from', 'user_to'),) User.add_to_class('following', models.ManyToManyField('self', through=Contact, related_name='followers', symmetrical=False)) I get the following error: Error: One or more models did not validate: auth.user: Accessor for m2m field 'following' clashes with related m2m field 'User.followers'. Add a related_name argument to the definition for 'following'. auth.user: Reverse query name for m2m field 'following' clashes with related m2m field 'User.followers'. Add a related_name argument to the definition for 'following'. auth.user: The model User has two manually-defined m2m relations through the model Contact, which is not permitted. Please consider using an extra field on your intermediary model instead. auth.user: Accessor for m2m field 'following' clashes with related m2m field 'User.followers'. Add a related_name argument to the definition for 'following'. auth.user: Reverse query name for m2m field 'following' clashes with related m2m field 'User.followers'. Add a related_name argument to the definition for 'following'.

    Read the article

  • Binding DataGridComboBoxColumn to a one to many entity framework relation

    - by Cristian
    I have two tables in the model, one table contains entries related to the other table in a one to many relations, for example: Table User ID Name Table Comments ID UserID Title Text I want to show a datagrid in a WPF window with two columns, one text column with the User name and another column with a combobox showing all the comments made by the user. The datagrid definition is like this: <DataGrid AutoGenerateColumns="False" [layout options...] Name="dataGrid1" ItemsSource="{Binding}"> <DataGrid.Columns> <DataGridTextColumn Header="Name" Binding="{Binding Path=Name}"/> <DataGridComboBoxColumn Header="Comments" SelectedValueBinding="{Binding Path=UserID}" SelectedValuePath="ID" DisplayMemberPath="Title" ItemsSource="{Binding Path=Comments}" /> </DataGrid.Columns> </DataGrid> in the code I assign the DataContext like this: dataGrid1.DataContext = entities.Users; The entity User has a property named Comments that leads to all the comments made by the user. The queries are returning data and the user names are shown but the combobox is not being filled. May be the approach is totally wrong or I'm just missing a very simple point here, I'm opened to learn better methods to do this. Thanks

    Read the article

  • What is the Best way to databind an ASP.NET TreeView for table with many to many parent child relati

    - by Matt W
    I've got a table which has the usual ParentID, ChildID as it's first two columns in a self-referencing tree data structure. My issue is that when I pull this out and use the following code: DataSet set = DA.GetNewCategories(); set.Relations.Add( new DataRelation("parentChildCategories", set.Tables[0].Columns["CategoryParentID"], set.Tables[0].Columns["CategoryID"]) ); StringBuilder buildXml = new StringBuilder(); StringWriter writer = new StringWriter(buildXml); set.WriteXml(writer); TreeView2.DataSource = new HierarchicalDataSet(set, "CategoryID", "CategoryParentID"); TreeView2.DataBind(); I get the error: These columns don't currently have unique values I believe this is because my data has children with multiple parent nodes. This is fine for my application - I don't mind if one row of data is rendered in multiple nodes of my TreeView. Could someone shed light on this please? It doesn't seem unreasonable to have a DataSet render XML which has nodes appearing in multiple places, but I can't figure out how to do it. Thanks, Matt.

    Read the article

  • Custom Repeater with hiractial Databinding

    - by Dooie
    Im using a Custom NestedRepeater Control for ASP.NET which can be found on code project The source is in c# which i have converted to vb and plugged into my solution, so far so good. The problem, im having is databinding to the repeater, my code behind looks like this... '' get all pages Dim navPages As DataSet = Navigation.getMenuStructure() navPages.Relations.Add(navPages.Tables(0).Columns("ID"), navPages.Tables(0).Columns("ParentID")) NestedRepeaterNavigation.RelationName = RelationName NestedRepeaterNavigation.DataSource = navPages NestedRepeaterNavigation.RowFilterTop = "ParentID is null" NestedRepeaterNavigation.DataBind() Then in the item template of my custom repeater im trying the following... <ItemTemplate> <img src="/pix.gif" height="10" width="<%#(Container.Depth * 10)%>"> <%# (Container.DataItem as DataRow)["DESCRIPTION"]%> <%# (Container.NbChildren != 0 ? "<small><i>(" + Container.NbChildren.ToString() +")</i></small>" "") %><small><i></i></small> </ItemTemplate> The databinding falls over; firstly that 'as DataRow' says it was expecting an ')'. And secondly that '!=' identifier expected. Is this due to the translation from c#, should the databinding be different?

    Read the article

  • Django Cannot set values on a ManyToManyField which specifies an intermediary model

    - by dana
    i am using a m2m and a through table, and when i was trying to save, my error was: Cannot set values on a ManyToManyField which specifies an intermediary model so, i've modified my code, so that when i save the form, to insert data into the 'through' table too.But now, i'm having another error. (i've bolded the lines where i think i am wrong) i have in models.py: class Classroom(models.Model): user = models.ForeignKey(User, related_name = 'classroom_creator') classname = models.CharField(max_length=140, unique = True) date = models.DateTimeField(auto_now=True) open_class = models.BooleanField(default=True) members = models.ManyToManyField(User,related_name="list of invited members", through = 'Membership') class Membership(models.Model): accept = models.BooleanField(User) date = models.DateTimeField(auto_now = True) classroom = models.ForeignKey(Classroom, related_name = 'classroom_membership') member = models.ForeignKey(User, related_name = 'user_membership') and in def save_classroom(request): if request.method == 'POST': form = ClassroomForm(request.POST, request.FILES, user = request.user) **classroom_instance = Classroom member_instance = Membership** if form.is_valid(): new_obj = form.save(commit=False) new_obj.user = request.user r = Relations.objects.filter(initiated_by = request.user) membership = Membership.objects.create(**classroom = classroom_instance, member = member_instance,date=datetime.datetime.now())** new_obj.save() form.save_m2m() return HttpResponseRedirect('/classroom/classroom_view/{{user}}/') else: form = ClassroomForm(user = request.user) return render_to_response('classroom/classroom_form.html', { 'form': form, }, context_instance=RequestContext(request)) but i don't seem to initialise okay the classroom_instance and menber_instance.My error os: Cannot assign "": "Membership.classroom" must be a "Classroom" instance. Thanks!

    Read the article

  • Why use SQL database?

    - by martinthenext
    I'm not quite sure stackoverflow is a place for such a general question, but let's give it a try. Being exposed to the need of storing application data somewhere, I've always used MySQL or sqlite, just because it's always done like that. As it seems like the whole world is using these databases, most of all software products, frameworks, etc. It is rather hard for a beginning developer like me to ask a question - why? Ok, say we have some object-oriented logic in our application, and objects are related to each other somehow. We need to map this logic to the storage logic, so we need relations between database objects too. This leads us to using relational database and I'm ok with that - to put it simple, our database rows sometimes will need to have references to other tables' rows. But why do use SQL language for interaction with such a database? SQL query is a text message. I can understand this is cool for actually understanding what it does, but isn't it silly to use text table and column names for a part of application that no one ever seen after deploynment? If you had to write a data storage from scratch, you would have never used this kind of solution. Personally, I would have used some 'compiled db query' bytecode, that would be assembled once inside a client application and passed to the database. And it surely would name tables and colons by id numbers, not ascii-strings. In the case of changes in table structure those byte queries could be recompiled according to new db schema, stored in XML or something like that. What are the problems of my idea? Is there any reason for me not to write it myself and to use SQL database instead?

    Read the article

  • InvalidArgument=Value of '3' is not valid for 'rowIndex'

    - by Devendra Dwivedi
    Hi all This is my code It is working for if 1 terminal that is having 3 services but it is not working for more than 3 services when I do then I have got following error message: InvalidArgument=Value of '3' is not valid for 'rowIndex' I have so tired to find this problem but couldn't get any solutions. Anybody please help me. MySqlCommand command = new MySqlCommand("VTerminalsLoad");//Procedure MySqlDataAdapter terminalAdapter = this.Database.ExecuteCommand(command); terminalAdapter.Fill(dataSet, "Terminals"); command = new MySqlCommand("VTServicesLoad");//Procedure command.Parameters.Add(new MySqlParameter("pVesselID", 1)); MySqlDataAdapter serviceAdapter = this.Database.ExecuteCommand(command);//Return Adaptor serviceAdapter.Fill(dataSet, "Services"); DataColumn[] parentColumns = { dataSet.Tables[0].Columns["SerialNo"], dataSet.Tables[0].Columns["VesselID"], dataSet.Tables[0].Columns["TerminalID"] }; DataColumn[] childColumns = { dataSet.Tables[1].Columns["SerialNo"], dataSet.Tables[1].Columns["VesselID"], dataSet.Tables[1].Columns["TerminalID"] }; DataRelation relationTS = new DataRelation("TerminalsServices", parentColumns, childColumns); dataSet.Relations.Add(relationTS); //Parent Table ListTerminal.DataSource = dataSet; //ListTerminal Parent datagridview ListTerminal.DataMember = "Terminals"; //Child Table ListServices.DataSource = dataSet;// ListServices Child datagridview ListServices.DataMember = "Terminals.TerminalsServices";

    Read the article

  • Graph-structured databases and Php

    - by stagas
    I want to use a graph database using php. Can you point out some resources on where to get started? Is there any example code / tutorial out there? Or are there any other methods of storing data that relate to each other in totally random/abstract situations? - Very abstract example of the relations needed: John relates to Mary, both relate to School, John is Tall, Mary is Short, John has Blue Eyes, Mary has Green Eyes, query I want is which people are related to 'Short people that have Green Eyes and go to School' - answer John - Another example: TrackA -> ArtistA -> ArtistB -> AlbumA -----> [ label ] -> AlbumB -----> [ A ] -> TrackA:Remix -> Genre:House -> [ Album ] -----> [ label ] TrackB -> [ C ] [ B ] Example queries: Which Genre is TrackB closer to? answer: House - because it's related to Album C, which is related to TrackA and is related to Genre:House Get all Genre:House related albums of Label A : result: AlbumA, AlbumB - because they both have TrackA which is related to Genre:House - It is possible in MySQL but it would require a fixed set of attributes/columns for each item and a complex non-flexible query, instead I need every attribute to be an item by itself and instead of 'belonging' to something, to be 'related' to something.

    Read the article

  • java partial classes

    - by Dewfy
    Hello colleagues, Small preamble. I was good java developer on 1.4 jdk. After it I have switched to another platforms, but here I come with problem so question is strongly about jdk 1.6 (or higher :) ). I have 3 coupled class, the nature of coupling concerned with native methods. Bellow is example of this 3 class public interface A { public void method(); } final class AOperations { static native method(. . .); } public class AImpl implements A { @Override public void method(){ AOperations.method( . . . ); } } So there is interface A, that is implemented in native way by AOperations, and AImpl just delegates method call to native methods. These relations are auto-generated. Everything ok, but I have stand before problem. Sometime interface like A need expose iterator capability. I can affect interface, but cannot change implementation (AImpl). Saying in C# I could be able resolve problem by simple partial: (C# sample) partial class AImpl{ ... //here comes auto generated code } partial class AImpl{ ... //here comes MY implementation of ... //Iterator } So, has java analogue of partial or something like.

    Read the article

  • Hibernate ManyToMany and superclass mapping problem

    - by Jesus Benito
    Hi all, I need to create a relation in Hibernate, linking three tables: Survey, User and Group. The Survey can be visible to a User or to a Group, and a Group is form of several Users. My idea was to create a superclass for User and Group, and create a ManyToMany relationship between that superclass and Survey. My problem is that Group, is not map to a table, but to a view, so I can't split the fields of Group among several tables -which would happen if I created a common superclass-. I thought about creating a common interface, but mapping to them is not allowed. I will probably end up going for a two relations solution (Survey-User and Survey-Group), but I don't like too much that approach. I thought as well about creating a table that would look like: Survey Id | ElementId | Type ElementId would be the Group or UserId, and the type... the type of it. Does anyone know how to achieve it using hibernate annotations? Any other ideas? Thanks a lot

    Read the article

  • sqlalchemy relation through another (declarative)

    - by clayg
    Is anyone familiar with ActiveRecord's "has_many :through" relations for models? I'm not really a Rails guy, but that's basically what I'm trying to do. As a contrived example consider Projects, Programmers, and Assignments: from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from sqlalchemy import Column, ForeignKey from sqlalchemy.types import Integer, String, Text from sqlalchemy.orm import relation from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class Assignment(Base): __tablename__ = 'assignment' id = Column(Integer, primary_key=True) description = Column(Text) programmer_id = Column(Integer, ForeignKey('programmer.id')) project_id = Column(Integer, ForeignKey('project.id')) def __init__(self, description=description): self.description = description def __repr__(self): return '<Assignment("%s")>' % self.description class Programmer(Base): __tablename__ = 'programmer' id = Column(Integer, primary_key=True) name = Column(String(64)) assignments = relation("Assignment", backref='programmer') def __init__(self, name=name): self.name = name def __repr__(self): return '<Programmer("%s")>' % self.name class Project(Base): __tablename__ = 'project' id = Column(Integer, primary_key=True) name = Column(String(64)) description = Column(Text) assignments = relation("Assignment", backref='project') def __init__(self, name=name, description=description): self.name = name self.description = description def __repr__(self): return '<Project("%s", "%s...")>' % (self.name, self.description[:10]) engine = create_engine('sqlite://') Base.metadata.create_all(engine) Session = sessionmaker(bind=engine) session = Session() Projects have many Assignments. Programmers have many Assignments. (understatement?) But in my office at least, Programmers also have many Projects - I'd like this relationship to be inferred through the Assignments assigned to the Programmer. I'd like the Programmer model to have a attribute "projects" which will return a list of Projects associated to the Programmer through the Assignment model. me = session.query(Programmer).filter_by(name='clay').one() projects = session.query(Project).\ join(Project.assignments).\ join(Assignment.programmer).\ filter(Programmer.id==me.id).all() How can I describe this relationship clearly and simply using the sqlalchemy declarative syntax? Thanks!

    Read the article

  • Exclude rows with Doctrine ORM DQL (NOT IN)

    - by Sheriffen
    I'm building a chat application with codeigniter and doctrine. Tables: - User - User_roles - User_available Relations: ONE user have MANY roles. ONE user_available have ONE user. Users available for chatting will be in the user_available table. Problem: I need to get all users in in user_available that hasn't got role_id 7. So I need to express in DQL something like (this is not even SQL, just in words): SELECT * from user_available WHERE NOT user_available.User.Role.role_id = 7 Really stuck on this one EDIT: Guess I was unclear. The tables are already mapped and Doctrine does the INNER JOIN job for me. I'm using this code to get the admin that waited the longest but now I need the user: $admin = Doctrine_Query::create() ->select('c.id') ->from('Chat_available c') ->where('c.User.Roles.role_id = ?', 7) ->groupBy('c.id') ->orderBy('c.created_at ASC') ->fetchOne(); Now I need to get the user that waited the longest but this does NOT work $admin = Doctrine_Query::create() ->select('c.id') ->from('Chat_available c') ->where('c.User.Roles.role_id != ?', 7) ->groupBy('c.id') ->orderBy('c.created_at ASC') ->fetchOne();

    Read the article

  • how to use a generated dbml classes to deserialize xml via linq?

    - by Eelco Meuter
    Hi, I have a complex data structure, which I boiled down in a dbml file with one class and 6 one-to-many relations. This data must also be read via xml. The xml structure is something like: <table id=1> <column 1></column 1> <column n></column n> <m-n table x> <column 1></column 1> </m-n table x> </table> where the tag <m-n table x> is one of the six related tables. The idea is to generate an xsd based upon the dbml, which I can use to create and validate a xml. This xml can hopefully deserialized into the dbml classes. The question is: Can this be done? If so, how do I generate the xsd. I use a sql server express 2008 r2 as backend. Thanks in advance for your time!

    Read the article

  • Order in many to many relation in Django model

    - by Pietro Speroni
    I am writing a small website to store the papers I have written. The relation papers<- author is important, but the order of the name of the authors (which one is First Author, which one is second order, and so on) is also important. I am just learning Django so I don't know much. In any case so far I have done: from django.db import models class author(models.Model): Name = models.CharField(max_length=60) URLField = models.URLField(verify_exists=True, null=True, blank=True) def __unicode__(self): return self.Name class topic(models.Model): TopicName = models.CharField(max_length=60) def __unicode__(self): return self.TopicName class publication(models.Model): Title = models.CharField(max_length=100) Authors = models.ManyToManyField(author, null=True, blank=True) Content = models.TextField() Notes = models.TextField(blank=True) Abstract = models.TextField(blank=True) pub_date = models.DateField('date published') TimeInsertion = models.DateTimeField(auto_now=True) URLField = models.URLField(verify_exists=True,null=True, blank=True) Topic = models.ManyToManyField(topic, null=True, blank=True) def __unicode__(self): return self.Title This work fine in the sense that I now can define who the authors are. But I cannot order them. How should I do that? Of course I could add a series of relations: first author, second author,... but it would be ugly, and would not be flexible. Any better idea? Thanks

    Read the article

  • Is ADO.NET Entity framework database schema update possible ?

    - by fyasar
    Hi All I'm working on proof of concept application like crm and i need your some advice. My application's data layer completely dynamic and run onto EF 3.5. When the user update the entity, change relation or add new column to the database, first i'm planning make for these with custom classes. After I rebuild my database model layer with new changes during the application runtime. And my model layer tie with tightly coupled to my project for easy reflecting model layer changes (It connected to my project via interfaces and loading onto to application domain in the runtime). I need to create dynamic entities, create entity relations and modify them during the runtime after that i need to create change database script for updating database schema. I know ADO.NET team says "we will be able to provide this property in EF 4.0", but i don't need to wait for them. How can i update database changes during the runtime via EF 3.5 ? For example, i need to create new entity or need to change some entity schema, add new properties or change property types after than how can apply these changes on the physical database schema ? Any ideas ?

    Read the article

  • howto distinguish composition and self-typing use-cases

    - by ayvango
    Scala has two instruments for expressing object composition: original self-type concept and well known trivial composition. I'm curios what situations I should use which in. There are obvious differences in their applicability. Self-type requires you to use traits. Object composition allows you to change extensions on run-time with var declaration. Leaving technical details behind I can figure two indicators to help with classification of use cases. If some object used as combinator for a complex structure such as tree or just have several similar typed parts (1 car to 4 wheels relation) than it should use composition. There is extreme opposite use case. Lets assume one trait become too big to clearly observe it and it got split. It is quite natural that you should use self-types for this case. That rules are not absolute. You may do extra work to convert code between this techniques. e.g. you may replace 4 wheels composition with self-typing over Product4. You may use Cake[T <: MyType] {part : MyType} instead of Cake { this : MyType => } for cake pattern dependencies. But both cases seem counterintuitive and give you extra work. There are plenty of boundary use cases although. One-to-one relations is very hard to decide with. Is there any simple rule to decide what kind of technique is preferable? self-type makes you classes abstract, composition makes your code verbose. self-type gives your problems with blending namespaces and also gives you extra typing for free (you got not just a cocktail of two elements but gasoline-motor oil cocktail known as a petrol bomb). How can I choose between them? What hints are there? Update: Let us discuss the following example: Adapter pattern. What benefits it has with both selt-typing and composition approaches?

    Read the article

  • pattern for the following condition in java

    - by zahir hussain
    hi i want to know how to write pattern.. for example : the word is "AboutGoogle AdWords Drive traffic and customers to your site. Pay through Cheque, Net Banking or Credit Card. Google Toolbar Add a search box to your browser. Google SMS To find out local information simply SMS to 54664. Gmail Free email with 7.2GB storage and less spam. Try Gmail today. Our ProductsHelp Help with Google Search, Services and ProductsGoogle Web Search Features Translation, I'm Feeling Lucky, CachedGoogle Services & Tools Toolbar, Google Web APIs, ButtonsGoogle Labs Ideas, Demos, ExperimentsFor Site OwnersAdvertising AdWords, AdSenseBusiness Solutions Google Search Appliance, Google Mini, WebSearchWebmaster Central One-stop shop for comprehensive info about how Google crawls and indexes websitesSubmit your content to Google Add your site, Google SitemapsOur CompanyPress Center News, Images, ZeitgeistJobs at Google Openings, Perks, CultureCorporate Info Company overview, Philosophy, Diversity, AddressesInvestor Relations Financial info, Corporate governanceMore GoogleContact Us FAQs, Feedback, NewsletterGoogle Logos Official Logos, Holiday Logos, Fan LogosGoogle Blog Insights to Google products and cultureGoogle Store Pens, Shirts, Lava lamps©2010 Google - Privacy Policy - Terms of Service" I have to search some word... for example "google insights" so how to write the code in java... i just write small code... check my code and answer my question... that code only use for find the search word, where is that. but i need to display some words front of search word and display some words rear of search workd... similar to google search... my code is Pattern p = Pattern.compile("(?i)(.*?)"+search+""); Matcher m = p.matcher(full); String title=""; while (m.find() == true) { title=m.group(1); System.out.println(title); } the full is orignal content, search s search word... thanks and advance

    Read the article

  • Is It Incorrect to Make Domain Objects Aware of The Data Access Layer?

    - by Noah Goodrich
    I am currently working on rewriting an application to use Data Mappers that completely abstract the database from the Domain layer. However, I am now wondering which is the better approach to handling relationships between Domain objects: Call the necessary find() method from the related data mapper directly within the domain object Write the relationship logic into the native data mapper (which is what the examples tend to do in PoEAA) and then call the native data mapper function within the domain object. Either it seems to me that in order to preserve the 'Fat Model, Skinny Controller' mantra, the domain objects have to be aware of the data mappers (whether it be their own or that they have access to the other mappers in the system). Additionally it seems that Option 2 unnecessarily complicates the data access layer as it creates table access logic across multiple data mappers instead of confining it to a single data mapper. So, is it incorrect to make the domain objects aware of the related data mappers and to call data mapper functions directly from the domain objects? Update: These are the only two solutions that I can envision to handle the issue of relations between domain objects. Any example showing a better method would be welcome.

    Read the article

  • A many-to-many relation joined disallows intellisense/lookup in joined table

    - by BerggreenDK
    I want to be able to select a product and retrieve all sub-parts(products) within it. My approach is to find the Product id and then retrieve the list of ProductParts with that as a parent and while fetching those, follow the key back to the Product child to get the name and details of each Part. I was hoping to use something similar to: part.linked_product_id.name I have two tables. One for [Product] and and a relation [ProductPart] that has two FK ID's to [Product] Table Product() { int ID; // (PRIMARY, NOT NULL) String Name; ... details removed for overview purpose... } Table ProductPart() { int Product_ID; // FK (linked with relation to Product/parent) int Part_Product_ID; // FK (linked with relation to Product/childen) ... details removed for overview purpose... } I have checked the SQL-diagram and it shows the two relations (both are one to many) and in my DBML they also looks right. Here is my LINQ to SQL snippet that doesnt work for me... wondering why my joins dont work as supposed. FaultySnippet() { ProductDataContext db = new ProductDataContext(); var list = ( from part in db.ProductParts join prod in db.Products on part.Part_Product_ID equals prod.ID where (part.Product_ID == product_ID) select new { Name = part.Part_Product_ID. ?? // <-- NO details from Joined table? ... rest of properties from ProductPart join... I hoped... } ); }

    Read the article

  • SQLite dataypes lengths?

    - by XF
    I'm completely new to SQLite (actually 5 minutes ago), but I do know somewhat the Oracle and MySql backends. The question: I'm trying to know the lengths of each of the datatypes supported by SQLite, such as the differences between a bigint and a smallint. I've searched across the SQLite documentation (only talks about affinity, only matters it?), SO threads, google... and found nothing. My guess: I've just slightly revised the SQL92 specifications, which talk about datatypes and its relations but not about its lengths, which is quite obvious I assume. Yet I've come accross the Oracle and MySql datatypes specs, and the specified lengths are mostly identical for integers at least. Should I assume SQLite is using the same lengths? Aside question: Have I missed something about the SQLite docs? Or have I missed something about SQL in general? Asking this because I can't really understand why the SQLite docs don't specify something as basic as the datatypes lengths. It just doesn't make sense to me! Although I'm sure there is a simple command to discover the lengths.. but why not writing them to the docs? Thank you!

    Read the article

  • SQLce DAL Linq to Sql or EntityFramework

    - by bretddog
    Hi, I'm learning databases, using SqlCe, and need business object to database mapping. Currently I try to decide if to use Linq to Sql, or EntityFramework. (I understand a bit L2S, but haven't familiarized with EF yet) The program will only be debeloped and used by myself, so I have good control of the priorities: I don't need to consider potential change of database type or data storage type, as I'm quite certain SQLce will stay sufficient. I DO expect continued development and changes to the data scheme while the program is in active use; change business object properties (Hence database columns), and possibly overall table scheme. So old data must be transported to new scheme. I also want to keep a decent degree of layer separation DAL/BLL, although this may not be necessary, it is good for me to learn these principles. My question is: With these priorities, would I have any benefit by choosing either Linq2Sql vs. EntityFramwork? (and please explain why) Btw, the project involves very simple table scheme with only 4-5 tables and very simple relations. Thanks!

    Read the article

  • Django notification get date one accesses a link

    - by dana
    hi there, i'm making a notification system, so that a user in a virtual community to be announced when someone sends him a message, or starts following him (the follow relation is like a friend relation, but it is not necessarily reciprocal) my view function: def notification_view(request, last_checked): u = Relation.objects.filter(date_follow>Notification.objects.get(last_checked=last_checked)) v = Message.objects.filter(date>Notification.objects.get(last_checked=last_checked)) if u: notification_type = follow if notice_settings == receive_notification or notice_settings == only_follow following = u if v: notification_type = message if notice_settings == receive_notification or notice_settings == only_messages message = v return render_to_response('notification/notification.html', { 'following': following, 'message':message, }, context_instance=RequestContext(request)) the models.py: class NoticeType(models.Model): follow = models.ForeignKey(Relations, editable = False) message = models.ForeignKey(Messages) classroom_invitation = models.ForeignKey(Classroom) class Notification(models.Model): receiver = models.ForeignKey(User, editable=False) date = models.DateTimeField(auto_now=True, editable = False) notice_type = models.ForeignKey(NoticeType, editable = False, related_name = "notification_type") sent = models.BooleanField(default = True) last_checked = models.DateTimeField(auto_now=True, editable = False) class NotificationSettings(models.Model): user = models.ForeignKey(User) receive_notifications = models.BooleanField(default = True) only_follow = models.BooleanField(default = False) only_message = models.BooleanField(default = False) only_classroom = models.BooleanField(default = False) #receive_on_email = models.BooleanField(default = False) my problem is: i want last_checked to be the time when someone acceses a link (the notification link). How can i possibily save that time? how can i get it? thanks in avance!

    Read the article

  • [Database] How to model this one-to-one relation?

    - by pbean
    I have several entities which respresent different types of users who need to be able to log in to a particular system. Additionally, they have different types of information associated with them. For example: a "general user", which has an e-mail address and "admin user", which has a workstation number (note that this a hypothetical case). Both entities also share common properties like first name, surname, address and telephone number. Finally, they naturally need to have a (unique) user name and a password to log in. In the application, the user just has to fill in his user name and password, and the functionality of the application changes slightly according to the type of the user. You can imagine that the username needs to be unique for this work. How should I model this effectively? I can't just create two tables, because then I can't force a unique constaint on the user name. I also can't put them all in just one table, because they have different types of specific information associated to them. I think I might need 3 seperate tables, one for "users" (with user name and password), one for the "general users" and another one for the "admin users", but how would the relations between these work? Or is there another solution? (By the way, the target DBMS is MySQL, so I don't think generalization is supported in the database system itself).

    Read the article

  • How to map a Dictionary<string, string> spanning several tables

    - by Kim Johansson
    I have four tables: CREATE TABLE [Languages] ( [Id] INTEGER IDENTITY(1,1) NOT NULL, [Code] NVARCHAR(10) NOT NULL, PRIMARY KEY ([Id]), UNIQUE INDEX ([Code]) ); CREATE TABLE [Words] ( [Id] INTEGER IDENTITY(1,1) NOT NULL, PRIMARY KEY ([Id]) ); CREATE TABLE [WordTranslations] ( [Id] INTEGER IDENTITY(1,1) NOT NULL, [Value] NVARCHAR(100) NOT NULL, [Word] INTEGER NOT NULL, [Language] INTEGER NOT NULL, PRIMARY KEY ([Id]), FOREIGN KEY ([Word]) REFERENCES [Words] ([Id]), FOREIGN KEY ([Language]) REFERENCES [Languages] ([Id]) ); CREATE TABLE [Categories] ( [Id] INTEGER IDENTITY(1,1) NOT NULL, [Word] INTEGER NOT NULL, PRIMARY KEY ([Id]), FOREIGN KEY ([Word]) REFERENCES [Words] ([Id]) ); So you get the name of a Category via the Word - WordTranslation - Language relations. Like this: SELECT TOP 1 wt.Value FROM [Categories] AS c LEFT JOIN [WordTranslations] AS wt ON c.Word = wt.Word WHERE wt.Language = ( SELECT TOP 1 l.Id FROM [Languages] WHERE l.[Code] = N'en-US' ) AND c.Id = 1; That would return the en-US translation of the Category with Id = 1. My question is how to map this using the following class: public class Category { public virtual int Id { get; set; } public virtual IDictionary<string, string> Translations { get; set; } } Getting the same as the SQL query above would be: Category category = session.Get<Category>(1); string name = category.Translations["en-US"]; And "name" would now contain the Category's name in en-US. Category is mapped against the Categories table. How would you do this and is it even possible?

    Read the article

  • Modelling deterministic and nondeterministic data separately

    - by Superstringcheese
    I'm working with the Microsoft ADO.NET Entity Framework for a game project. Following the advice of other posters on SO, I'm considering modelling deterministic and nondeterministic data separately. The idea for this came from a discussion on multiplayer games, but it seemed to make sense in a single-player scenario as well. Deterministic (things that aren't going to change during gameplay) Attributes (Strength, Agility, etc.) and their descriptions Skills and their descriptions and requirements Races, Factions, Equipment, etc. Base Attribute/Skill/Equipment loadouts for monsters Nondeterministic (things that will change a lot during gameplay) Beings' current AttributeModifers (Potion of Might = +10 Strength), current health and mana, etc. Player inventory, cash, experience, level Player quests states Player FactionRelationships ...and so on. My deterministic model would serve as a set of constants. My nondeterministic model would provide my on-the-fly operable data and would be serialized to a savegame file to maintain game state between play sessions. The data store will be an embedded SQL Compact database. So I might want to create relations between my Attributes table (deterministic model) and my BeingAttributeModifiers table (nondeterministic model), but how do I set that up across models? Det model/db Nondet model/db ____________ ________________________ |Attributes | |PlayerAttributeModifiers| |------------| |------------------------| |Id | |Id | |Name | |AttributeId | |Description | |SourceId | ------------ |Value | ------------------------ Should I use two separate models (edmx) that transact with a single database containing both deterministic-type and nondeterministic-type tables? Or should/can I use two separate databases in one model? Or two models each with their own database? With distinct models/dbs it seems like this will get really complicated and I'll end up fighting EF a lot, rolling my own transaction code, and generally losing out on a lot of the advantages of the framework. I know these are vague questions, I'm just looking for a sanity check before I forge ahead any further.

    Read the article

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