I have a query that needs to retrieve a string value based on a function and it needs to join to another table using that string.
Background Info: I have one table that contains my company's data and one column in particular contains company id's (integers). I have another table that we import data into which contains our vendor data an...
Say I've got a domain model created from C# classes like this:
public class MyClass
{
public string MyProperty { get; set; }
}
Along with the model, I have defined repository interfaces classes for IoC.
Now, I'm trying to turn this POCO domain model into a set of Entity classes using LINQ mapping. (This approch was recommended in a b...
var auditAgencyRecords = (from ag in db.Agencies
join ara in db.AuditRuleAccounts on ag.Agency_Id equals ara.AgencyID
join arr in db.AuditRuleResults on ara.AuditRuleAccountID equals arr.AuditRuleAccountID
join are in db.Audi...
I have no code behind and the above error keep prompting on INSERT. The DBML is refresh!
Exception Details: System.Data.Linq.DuplicateKeyException: Cannot add an entity with a key that is already in use.
...
How compatible is ORM and existing databases that have a lot of constraints (particularly unique key constraints/unique indexes beyond primary keys) enforced within the database itself?
(Often these are preexisting databases, shared by numerous legacy applications. But good database modeling practice is to define as many constraints as ...
DBML
I have the following entities in my dbml: (made up for an example)
Book <- Media -> AuthorsForMedia <- Author
The arrows are the relationships in my dbml.
A book is a type of media, and an instance of a book has a media property with the values common to all media in it. AuthorsForMedia is an intersecting table with an AuthorI...
I have started using Linq to SQL for a project im working on and i have run into a problem when ordering by a DateTime field but since the DateTime allows nulls the nulls are coming up as less than the actual dates in there.
So i pretty much want the ones with a date to be at the top (ordered either way) then all the ones with no date s...
I'm a long-time user of the DevExpress XPO library. It has many great features, but there are a few weaknesses:
When saving an existing object, all properties are sent in an update query; changes are tracked on a per-object basis, not per-property.
Optimistic locking is done on a per-object basis, rather than per-column.
When an optim...
I'm running into an issue writting this Lamda expression in VB. a1 is what is giving me syntax errors and a2 seems to be ok.
In addition, I have a class called UserInfo, how can I pass values to the class so that I can use when building my datatable?
Code that I'm trying to add:
Dim a1 = From rows In db.tPDMLinkUsages _
Where (ro...
How do you group by multiple columns in LINQ TO SQL?
db.Table.GroupBy(a => a.column1.ToString() + a.column2.ToString())
It seems ugly and with poor performance, and I don't even know if it works. Which is the right way to do it?
...
I have the following query I'm using (which mostly came from the help I received here):
public IEnumerable<Entities.AuditAgency> GetAuditRuleAgencyRecords(IEnumerable<Entities.AuditRuleEnterprise> rules)
{
using (LinqModelDataContext db = new LinqModelDataContext())
{
// Left-Outer Joins on Agency and...
I'm making an application that will analyze real-time data that has been stored to a SQL CE database. When I test the application as it is built now, with LINQ to SQL, I get slow results and I need to rethink how to do this.
To save me some time, can I trust that L2S is just as fast as the 'old' SqlCe methodes were? I like L2S and would...
We are experimenting with several different persistence layers for our current project. We are trying for a POCO/PI approach. One of our candidates is LinqToSql. I am following the work presented by Vijay Mehta in "Pro LINQ Object Relational Mapping with C# 2008", in which the POCOs and the mapping files are created by hand.
I have t...
I have this columns
id int primary key,
code int not null
I want to delete all items where code equals to one of the items in a
IEnumerable<int> someEnumerable
One possible way is using iteration. But I wanna do it without explicit iteration (for, foreach). Another way is by doing this:
var result = db.table.Where(a => someEnumera...
Is there any way to refactor this code so that it can omit unnecessary WHEREs and JOINs if the values passed into the function are null (this code works just fine right now if all parameters are passed in)? The "SearchItems" and "ItemDistance" functions are table-level functions for performing fulltext search and distance calculations, ...
I was wondering what would be the best way to create LINQ-to-SQL classes to deal with a given entity which is present in 10 different data sources. Let's say I've got the same database in 10 different countries, each of them with a Customers table, and my goal is to access all of them programatically. Should I either create:
a single A...
Hello everybody.
I am trying to learn some ASP.NET MVC.
Please bear with me but asp.net mvc is the first mvc framework i ever tried to learn. I do plan to learn more about mvc framework in different languages, but for now i got asp.net mvc.
I am fairly good with asp.net forms and love them, but would like to have another asp.net tool...
I have a problem with linqdatasource. I have gridview in my page and I set it's datasource to linqdatasource,also I set AllowPaging="True" , AllowSorting="True".
<asp:GridView ID="cityGrid" runat="server" AutoGenerateColumns="False"
DataKeyNames="CityId" AllowPaging="True"
AllowSorting="True" DataSourceID="LinqCityData">
Now in lin...
I've been using StructureMap for sometime now but I'm far from an expert. My problem is simple, I'm trying to configure SM via code (Registry) to use a particular constructor when creating an instance of a repository object.
Here are my 2 constructors (note neither is the greediest).
public BusinessUnitRepository( IDatabase database )...