LINQ-to-SQL - Join, Count
I have following query: var result = ( from role in db.Roles join user in db.Users on role.RoleID equals user.RoleID where user.CreatedByUserID == userID orderby user.FirstName ascending select new User...
I have following query: var result = ( from role in db.Roles join user in db.Users on role.RoleID equals user.RoleID where user.CreatedByUserID == userID orderby user.FirstName ascending select new User...
The project I'm working on has quite a lot of "look up" data associated with it. For this reason, on the first instantiation of the class that handles this, I set static IEnumerable's with all the lookup data, thusly: private static IEnumerable<Kiosk> _kiosks; private static IEnumerable<Paper> _papers; private static IEnumerable<NewsAge...
What are the pro's and con's of using "Linq to SQL" and core ADO.NET technology for access databases? ...
I'm using LinqToSql like this with a CheckBoxList in ASP.NET: var teachers = from x in dc.teachers select x; cbl.DataSource = teachers; cbl.DataTextField = "name"; cbl.DataValueField = "teacherID"; cbl.DataBind(); I want to display both "firstname" and "name" in the DataTextField however. I found this solution but I'm using ...
Dear .Net Linq experts, I am looking for a way to query for products in a catalog using filters on properties which have been assigned to the product based on the category to which the product belongs. So I have the following entities involved: Products -Id -CategoryId Categories [Id] Properties [Id, CategoryId] PropertyValues ...
How can i use regular expressions with linq to sql in the asp.net mvc(C#) application? The columns in my MSSQL table (Products) has some special characters like (, - % ',.....). While searching for a product i need to search without that special chareters. For ex.: I have a product say (ABC-Camp's / One), when i search for "abccamp",...
hi, i have wrote a method that filters output with provided query and return it. when one Where excuted; it return correct output but when more than one Where excuted; output is null and Exception occured with message "Enumeration yielded no results". why? how i can fix it? public IQueryable<SearchResult> PerformSearch(string query, int...
I have a SQL Server 2008 database with > 300 tables. The application I have to design is an Windows Forms app, .NET 3.5, C#. Which is the best way to work with Linq-to-SQL ? I intend to make a datacontext for each business entity. Is there any problem ? I need to know if this way of working with Linq-to-SQL has any disadvantage or ca...
I have a class User and a class History. History has 'User' property, and User has 'Histories' property. So there's a database relationship. But when I create a new User history class and set UserID property, I can't access the 'User' property. var history = new History { UserID = 1 }; // history.User = null ??? How can I get the use...
I have this strange behavior. Im Loading some entities in a List<> and append to a grid. When double click the grid i take the row cast to the entity and append to a property. I have changed some things in my database and code and now i get this exception while i never wanted to check something on this Entity Reference. Any Ideas? ...
Hi all, I took a task from my manager that convert SQLProvider2008 in sharpMap tool from ADO to LINQ In brief, Author of this tool take connectio string for your DB then his tool draw the map from your DB So my task will be to get any DB ,so user of this tool will create datacontext for his DB then pass it to me but at run time I can...
Is this the easiest way to insert a record with Linq to Sql when there's a many-to-many relationship, or is there a better/cleaner way? I wasn't sure why things weren't working at first, but when I added a second SubmitChanges() it worked. Why was this necessary? Would be grateful if someone could clarify this a bit! private void Insert...
What is the best practice for encrypting the connectionStrings section in the web.config file when using LINQ TO SQL? ...
Hi, I keep getting the same error: Entities in 'VlaamseOverheidMeterEntities.ObjectMeter' participate in the 'FK_ObjectMeter_Meter' relationship. 0 related 'Meter' were found. 1 'Meter' is expected. I have the following table structure: Meter 1 <- * ObjectMeter * -> 1 VO_Object It is always the same scenario: The first meter is adde...
I'm currently working on an Web Application similar to Steamworks (if you don't know what it is, its a service for games to store Achievements, Stats etc). The major problem I've run into in the development of this is the addition of new databases for games after the application has been deployed. I'm using LINQ-to-SQL to query the data...
Hey everyone, I'm haing a few problems updating a row in my database using Linq2Sql. Inside of my model I have two methods for updating and saving from my controller, which in turn receives an updated model from my view. My model methods like like: public void Update(Activity activity) { _db.Activities.InsertOnSub...
I have my project in .NET that uses a database in SQL Server. I'm using Linq-to-SQL, sometimes when the project throws me an exception (Constraint) in a part of the project this same error keeps showing in other part of the project when I do another thing with the database. Like when I do an insertion and I had before an exception on del...
I'm performing a query with a sort in the Selecting event of the LinqDataSource. I'm then casting my query to a list and assigning it to the result. I'm using this data source in an ASP.NET gridview. I can see the list is sorted but when the ASP.NET gridview does not seem to be respecting the sort order. How can I get the gridview to r...
I'm using a Silverlight 4 WCF RIA Services demo application that uses LinqToSql, that works well. I add a new database table, move the new table to the LinqToSql designer and build the project I add a new DomainService class I get a dialog with the only option to create an empty DomainService and no DataContext classes are available...
I have two objects (Foo and Bar) that have a one-to-zero-or-one relationship between them. So, Foo has a nullable foreign key reference to Bar.ID and a (nullbusted) unique index to enforce the "1" side. Bar.ID is an int, and so Foo.BarID is a nullable int. The problem occurs in the LINQ-to-SQL DBML mapping of .NET types to SQL datatypes...