Default value in sql database design
Is it always good practice to provide default values for integer-like fields? I use linq for database access. ...
Is it always good practice to provide default values for integer-like fields? I use linq for database access. ...
Hi, I'm trying to understand some fundamental best practices using Entity Framework. My EDM design has Group and User entities which the Group may contain users and other groups. The question is: What is the best way to retrieve the users from a group? For getting the groups its easy, just creating the context object and creating a ...
I have an EF 4.0 model that has a parent child relationship (say order and orderdetails) order { [primative] orderid, ordername, ordershipping [navigation] orderdetails } orderdetail { orderdetailid, orderpartid, orderquantity, orderpartname } My question is how do i load orders with orderdetails where the ...
I tried to insert Order Row with the Existing User using LINQ. The program should only insert the Order & Order Details because the User is already exist and I don't want to add the new user for each order. Instead of that, the program is now inserting Order, OrderDetails together with User. So, I am getting duplicate users in my us...
I am trying to distinct on multiple columns and get datarows from datatable. but getting error. Dim query As IEnumerable(Of DataRow) = (From row As DataRow In SourceTable.AsEnumerable() _ Select row.Field(Of String)("ColumnName1"), row.Field(Of String)("ColumnName2") ).Distinct() below e...
I'm planning a new service for my ASP.NET MVC app and want to use tags. I've never really been too fond of tags, but SO delivers so I'll give it a shot. Here's the simplified schema I'm thinking about: Post Table ------------------ PK PostId BigInt (or perhaps uniqueidentifier) ...more post related fields... Tags nvarchar(200) Then I...
I need to compare two dictionaries and to update another dictionary with unmatched items The two dictionaries are like Dictionary<String, List<String>> DICTONE = new Dictionary<string, List<String>>(); Dictionary<string, List<String>> DICTTWO = new Dictionary<string, List<String>>(); And the contents DICTONE["KEY1"]="A" ...
Is there a way to find in a List all items of a certain type with a Linq/Lambda expression? Update: Because of the answers, I realize the question wasn't specific enough. I need a new List with only the items of a specific type. In my case, the class hasn't got any subclasses, so no need to take inheritance into account. ...
I am attempting to bind linq-to-xml query to a gridview. I have the following XML <?xml version="1.0" encoding="utf-8" ?> <thesaurus xmlns="x-schema:tsSchema.xml"> <diacritics_sensitive>0</diacritics_sensitive> <expansion> <sub>satellite navigation</sub> <sub>sat-nav</sub> <sub>Sat Nav</sub> <sub...
This IS a delayed execution problem. However, my issue stems from the fact that I cannot ascertain WHY this execution is delayed sometimes, and not other times. Code: IList<LineItem> freeFlatItems = new List<LineItem>(); if(QualifyFreeFlatShipping) freeFlatItems = lineItems.Where(l => l.FlatShippingRate != null).ToList(); decimal...
Guys, I have a simple class representing an object. It has 5 properties (a date, 2 decimals, an integer and a string). I have a collection class, derived from CollectionBase, which is a container class for holding multiple objects from my first class. My question is, I want to remove duplicate objects (e.g. objects that have the same d...
I would like a third column "items" with the values that are grouped. Dictionary<string, int> dic = new Dictionary<string, int>(); dic.Add("a", 1); dic.Add("b", 1); dic.Add("c", 2); dic.Add("d", 3); var dCounts = (from i in dic group i by i.Value into g select new { g.Key, count = g.Count()}); var a = dCounts.Where(c =...
This code is giving me this error: The object cannot be deleted because it was not found in the ObjectStateManager using (var context = new MvcApplication4.Entity.test2Entities()) { var q = (from t in context.tag where t.tag_id == tag select new ...
Say I have the following string lists: string[] list1 = { "one", "two", "three", "four"}; string[] list2 = { "one", "two", "three" }; string[] list3 = { "three", "two", "one" }; I need a query that allows me to compare list2 to list1 and return true if all the strings in list2 exist in list1, in the same order as list2. So, such a q...
hi is it possible to bind gridview inside of usercontrol from content page, if so how? ...
I need the fields in 1 table contingent on 1 property matching rows in another table. I can write this query in SQL with a subquery as such: SELECT * FROM Table1 WHERE Property1 IN ( SELECT Property1 FROM Table2 WHERE Property0 = 1 ) But I read here that it's less complicated and just as easy to write with a join, which I ...
I would like to get the list of albums (Distinct) which was sung by the artistId=1 I am very new to LINQ to SQL and do not know how to join multiple tables. Please see the database diagram below: SingBy is the middle table between Track and Artist. How could I achieve this? ...
I am trying to get distinct rows based on multiple columns (attribute1_name, attribute2_name) and get datarows from datatable using Linq-to-Dataset. I want results like this attribute1_name attribute2_name -------------- --------------- Age State Age weekend_percent Age statebreakl...
I'm currently writing a WCF web service that uses LINQ to SQL to fetch work with a SQL database. I have a Users table that had an integer that stores how many requests to the service the user has done. During testing I'm getting some concurrency probs updating the integer if its being done at the same time. What would be the best way t...
Hi, I have some labels on my Page (e.g. Label1...Label100). I don't want to loop through all Labels to check if Text property is = "" (or string.Empty, whatever), so this's my question - is it possible to use LINQ or Lambda Expression to get all "empty" labels ? ...