I have to insert some data periodically in my SQL Server database. But the feeds where I read the data repeats some data that was inserted before. When I use Linq-to-SQL to insert into the DB either some data is duplicated, or a primary key violation exception is raised, depending on the primary key.
How to insert the data without dupli...
I have a Silveright app that allows users to specify filters on a few different sets of persisted data. The persisted data can be XML or a relational database table. I'm using nHibernate for the database layer as I need to support different database options, Postgresql and MySQL at a minimum. The filter fields vary depending on which dat...
Update
I decided to iterate through the Data.DataTable and trimmed the values there.
Utilizing SirDemon's post, I have updated the code a little bit:
Sub test(ByVal path As String)
Dim oData As GSDataObject = GetDataObj(path)
EmptyComboBoxes()
Dim oDT As New Data.DataTable
Try
Dim t = From r In oData.GetTable(St...
I added a reference to the System.Core assembly. The web.config now has:
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
The IIS is set to use ASP.NET version 2.0.50727
Though intellisense shows the extension methods, the compiler does not understand the linq syntax. I can use Linq in ...
What are some pros and cons of using linq over stored procedures?
...
The code, with two Linq-to-SQL queries, that I am trying to optimize is below:
var maxAInstant =
(
from a in db.As
select a.Instant
)
.Max();
var maxBInstant =
(
from b in db.Bs
select b.instant
)
...
I have a service level methods, which make few changes to database and I want them to use transaction control. Such methods can do following:
- LINQ SubmitChanges() functionality
- Calls to StoredProcedures
Component users can combine set of such elementary operations into something bigger.
I see that there is nice class TransactinSco...
In my model I have Address as a base class and MailingAddress, Email, and Phone as subclasses of Address. A Person has an address so query to get a person who has an Oakland Mailing address would look like this:
var peopleInOakland = from p in entities.DbObjectSet.OfType<Person>()
from a in p.Addresses.OfTy...
Anyone have experience with compiled query syntax for VB? I'm used them a few times in C#, but can't seem to make the translation. My code is below:
#Region "Locals"
'Data context objects '
Private _dbOrderInfo As New OrderInfoDataContext
#End Region
#Region "Delegates"
Public Shared ReadOnly Func(_dbOrderInfo, Boolean, IQu...
I have some code where I am using a Linq-To-SQL DataContext to add and modify records in a table.
I've run into a situation where I add a few records via InsertOnSubmit, and then I want to modify a record.. but this record may already be in the table, or it may be one of the ones I am inserting. So this:
db.MyTable.Single(t => t.Id ==...
Is there a way in Linq to do an OrderBy against a set of values (strings in this case) without knowing the order of the values?
Consider this data:
A
B
A
C
B
C
D
E
And these variables:
string firstPref, secondPref, thirdPref;
When the values are set like so:
firstPref = 'A';
secondPref = 'B';
thirdPref = 'C';
Is it possible to o...
Hello, may someone could help me on one problem in query LINQ to SQL Visual Basic.
My database has three tables,
* Students(StudentID, StudentName),
* Class(ClassID, ClassDate),
* Attendance(StudentID, ClassID) which Attendance tables is the junction table between Students and Class.
For example:
Students
StudentsID.............St...
I would like to get a LINQ-to-SQL query that returns only one item, not a collection of them?
For example, I have a list of products with a particular name. There are no products with duplicate names in the database, so I want to be able to query and return just that instance of that product.
Products product = from p in _productCon...
I have a query that contains about 10 joins. Using a List View and Linq Data Source it pages fine against SQL2008 but fails to produce the correct result when run against SQL2000. No exception is thrown but the results are clearly out of order and at times, the same page is returned. Reading through the LINQ Docs, paging against queries ...
Single and multiple lists
Consider the following lists:
List<Int32> appleIdentities = new List<int>(new[] { 1, 2, 3 });
List<Int32> chocolateIdentities = new List<int>(new[] { 2, 3, 4 });
List<Int32> icecreamIdentities = new List<int>(new[] { 11, 14, 15, 16 });
Using LINQ to SQL; is it possible to wite a statement which translates in...
I am writing a LINQ provider to a hierarchal data source. I find it easiest to design my API by writing examples showing how I want to use it, and then coding to support those use cases.
One thing I am having trouble with is an easy/reusable/elegant way to express "deep query" or recursion in a LINQ statement. In other words, what is th...
Hey guys, I'm trying to get my head around LINQ and FP, so forgive me if this is naive. I'm trying to do some string parsing using LINQ and mapping onto a function, so I need to split my string up into smaller strings.
I want to split the array up into smaller lists of two. Can I use a reduce (.Aggregate()) to do this? I was trying t...
Given Linq and technologies like i4o is there any real reason why an object oriented database management system won't be a viable alternative to a relational database management system for new projects starting in the next 3 to 5 years?
...
I know that in most cases it`s more useful to learn more complicated technology/language and then easy one than vice versa.
But, actually, time to do university tasks is limited. If I first learn LINQ, then go for SQL, would it be hard for me to use and learn sql?
EDIT
The task I need to do is to work with database and get some data from...
Hello,
I'm trying to join one Linq collection from Data Base and one from XML file. Is this possible? I always get: Local sequence cannot be used in LINQ to SQL implementation of query operators except the Contains() operator.
Here is my code:
MyDataContext dc = new MyDataContext();
XElement CustomData;
var pages = from p in dc.Pages
...