I have spent the afternoon trying to wrap my mind around how to translate the following query into LINQ, but I can't quite get there.
declare @productId int; set @productId = 3212;
select * from InformationData data where productId = @productId and orgId = 1
and exists(
select id from (
select coalesce(id1.id, id2.id, id3.id)...
I come from the asp.net world where we'd use an objectdatasource, hooked up to data access layer, and set it's ConflictDetection property to "CompareAllValues". There is an OldValuesParameterFormatString on the ObjectDataSource that you use to identify old value parameters.
The sql procedure that does an update would then require both n...
Hello all,
I have searched for this, but still can't seem to get this to work for me. I have an array of Id's associated with a user (their Organization Id). These are placed in an int[] as follows:
int[] OrgIds = (from oh in this.Database.OrganizationsHierarchies
join o in this.Database.Organizations on oh.Org...
This is my sample code
var returnResult = datacontext.Searchresult('1');
returnResult is of System.Data.Linq.SqlClient.SqlProvider.SingleResult
Trying to serialize it using DataContractSerializer results in error below.
{"Type 'System.Data.Linq.SqlClient.SqlProvider+SingleResult`1[Service.SearchResult]' cannot be serialized. Conside...
EDIT 1
I apologize but after reading the 2 suggested articles I still don't understand what I should use. I understand that using IQueryable is not preferred for various reasons but does that eliminate IEnumerable as well? Is a DataTable really my best option?
In short, I guess, what is the preferred Return type?
I have the followi...
This post on SO answers most of the questions I have (much thanks to Pure.Krome for the thorough response) about how to build a query that returns multiple results. However, in the case that I'm working with my tables that are coming back are sort of dependent on how the proc behaves. Can't change the proc. The results that are coming ba...
In the tutorials for ASP.Net MVC, the LINQ to Entities code looks like:
public class MyController : Controller
{
private Models db;
public ActionResult Index()
{
db = new Models();
var foo = (from f in db.foo select f).ToList();
return View(foo);
}
}
I'm guessing this has something to do with t...
In my humble opinion, Microsoft is changing rules about database managing each four or five years. I remember old days when RDO was the solution to connect to SQL server. I refresh my knowledge to use ADO because RDO was obsolete. ADO was very good and effective, but not so long ago, I found myself programming and refreshing again my kno...
say i have a nvarchar field in my database that looks like this
1, "abc abccc dabc"
2, "abccc dabc"
3, "abccc abc dabc"
i need a select LINQ query that would match the word "abc" with boundaries not part of a string
in this case only row 1 and 3 would match
...
I'm trying to override the equality (==) operator in C# to handle comparing any type to a custom type (the custom type is really a wrapper/box around null).
So I have this:
internal sealed class Nothing
{
public override bool Equals(object obj)
{
if (obj == null || obj is Nothing)
return true;
else
return false;
}
public...
I've hit on the idea of creating static methods on the partial Linq queries such as
public partial class User
{
public static User FindByGuid(string guid, ApplicationDataContext context)
{
return context.Users.Where(x => x.GUID == guid).Single();
}
}
So, for example, I can easily find a user by doing:
using (var c...
Dim tenItem = From t In _InvalidFeeList _
From i In ItemCount _
Where t.FeeCode <> i.FeeCode _
Order By t.Description _
Ascending Take (10)
Dim feeList As List(Of AccessorialFee) = tenItem.ToList()
I am getting "Can not convert to System.g...
I've read that it's unwise to use ToUpper and ToLower to perform case-insensitive string comparisons, but I see no alternative when it comes to LINQ-to-SQL. The ignoreCase and CompareOptions arguments of String.Compare are ignored by LINQ-to-SQL (if you're using a case-sensitive database, you get a case-sensitive comparison even if you a...
I want to execute a function on all the objects within a List of objects using LINQ. I know i saw something similar on SO before but after several failed search attempts, i am posting this question
...
Hi,
Is there any quick way to create a table in a dataset and fill it with the schema from an IQueryable (Data is not coming from EF or Linq2Sql)? I need this for binding a grid to my data.
Thanks,
Roy
...
The following code gives a NullReferenceException since XPathSelectElement can't navigate through the XPath expression I've given:
String description = (String)node.XPathSelectElement("//car").Attribute("description");
I've debugged this and verified that the node is being read correctly, and that the elements in my XPath are capitali...
is there a way to select one per every 5 records in sql server with linq?
...
I need to write a query in t-sql or linq that matches db records that contain the most of the user input words.
exmaple:
nvarchar field in db: "The quick brown fox jumps over the lazy dog"
User input: "brown cow"
The program would match that record because it has the word brown.
let me know if i need to provide more examples.
...
Hi,
I am new to the entity framework and wondered, when the data is actually taken from the database. If I e.g. does:
from order in orderQuery where order select car;
is the data then selected from the database, or is it first when I manipulate it like the code below?
(from order in orderQuery where order select car).ToList();
...
OK,
This is something that I cannot believe I have not been able to figure out -- please tell me I am missing someting simple...
I have a datagrid, I am filling it with Linq as well as a custom class to add data to it.
Afterwards, I need the data in a specific order - it seems to ignore me.
How do I change a columns properties, like ...