How can I get WCF to allow the following?
Dim EmployeeID as Integer = 10
Dim emp As New WcfServiceLibrary1.Employee(EmployeeID)
Response.write (emp.LastName)
Currently I have to do this because I can't figure out a way for WCF to allow for Parameterized Constructors:
Dim EmployeeID as Integer = 10
Dim emp As New WcfServiceLibrary1.Em...
Is there a way to perform a top (Take) linq query using percentage? The T-SQL would have been:
SELECT TOP 20 PERCENT ...
But LINQ seems to only want an int.
It seems that I would have to do a count and then a take. Any suggestions?
...
I have a table 'lasttraces' with the following fields:
Id, AccountId, Version, DownloadNo, Date
The data looks like this:
28092|15240000|1.0.7.1782|2009040004731|2009-01-20 13:10:22.000
28094|61615000|1.0.7.1782|2009040007696|2009-01-20 13:11:38.000
28095|95317000|1.0.7.1782|2009040007695|2009-01-20 13:10:18.000
28101|15240000|1.0.7....
I am using LINQ for the first time and I am running into some behavior I don't fully understand with the DataContext. Hopefully StackOverflow can help.
Basically, it seems like once my DataContext encounters an exception, it either caches that exception or never fully recovers. In my specific case, once I try to pass a string that is to...
I was just wondering what it is and I figured you guys could do a better job of answering it then google could. I know it's for databases, but what does it do?
...
I'm using Linq2Sql for my asp.net mvc project and so far it has worked out just great.
Now however I need to implement a "key word search" that searches for x key words over about 20 fields spread over 10 joined tables that are joined with a maximum depth of 3 levels.
The linq function is really simpel, but the generated query is just to...
I'm getting back into .NET development after a couple years and it seems that now, especially with LINQ, the way you access your data has changed and become much easier. For instance, in a ASP.NET MVC website, I can:
Add Item
add LINQ-to-SQL classes
drag on database tables onto the LINQ-to-SQL Object Relational Designer, click save
ac...
Hi
I'm writing an .NET 3.5 web application that is using LinqToSql for the basic database stuff. I'd like to use the nLog library for logging. This library can log to a database using good ol' fashioned stored procedures (not that there is anything wrong with that..) but I'd like to use the LingToSql DataContext to log to the database
...
I'm looking for the shortest code to create methods to perform common operations on items in an IEnumerable.
For example:
public interface IPupil
{
string Name { get; set; }
int Age { get; set; }
}
Summing a property - e.g. IPupil.Age in IEnumerable<IPupil>
Averaging a property - e.g. IPupil.Age in IEnumerable<IPupil>
Buildi...
I decided to use LINQ to SQL in my personal project after hearing lots of goods. Is there any thing I need to taken care before start using it (during initial design)?
...
How can I convert a List to an IEnumerable and back again.
The reason I want to do this is to run a series of LINQ statements on the List i.e. sort etc
...
I'm setting up a public site and the first thing on my mind is SQL injection. I have some text fields I'm saving and am using linq to update/write to the database. Am I safe using linq?
This example is creating the user account.
Data.MemberRegistrationDataContext context = new MemberRegistrationDataContext();
...
I've got some code which accepts a DataTable as a parameter and calculates the total of several of the columns in the DataTable. I thought it might be nice to be able to pass in a lambda expression which would perform a filter on the column I'm totaling.
Here's a portion of the code:
public TrafficTotals CalculateTotals(DataTable tabl...
If I have a table with a title column and 3 bit columns (f1, f2, f3) that contain either 1 or NULL, how would I write the LINQ to return the title with the count of each bit column that contains 1? I'm looking for the equivalent of this SQL query:
SELECT title, COUNT(f1), COUNT(f2), COUNT(f3) FROM myTable GROUP BY title
I'm looking fo...
Using LINQ to SQL
db.Products.Where(c => c.ID == 1).Skip(1).Take(1).ToList();
executes
SELECT [t1].[ID], [t1].[CategoryID], [t1].[Name], [t1].[Price], [t1].[Descripti
n], [t1].[IsFeatured], [t1].[IsActive]
FROM (
SELECT ROW_NUMBER() OVER (ORDER BY [t0].[ID], [t0].[CategoryID], [t0].[Name
, [t0].[Price], [t0].[Description], [t0].[...
When I call a Linq (not Linq-for-SQL, just simple in-memory Linq) - what locale it uses to compare objects, and how can I affect it?
E.g.
string[] a = { "a", "b", ... };
string max = a.Max();
What locale is used here - current, invariant? How can I affect it?
The comparision seems to be case-insensitive, what if I want to find case...
hi
My Sql Query in Vb.net is like this:
Dim TableName As String ="City"
Dim Str As String="Select * from "+TableName+""
I got TableName from another Form .how we can do this in linq?
can we use TableName in Linq query dynamically?
please help me?
...
What is the linq equivalent of the following statement ?
IF NOT EXISTS(SELECT UserName FROM Users WHERE UserName='michael')
BEGIN
INSERT INTO Users (UserName) values ('michael');
END
also can you suggest any sql-to-linq converters? I am currently using LINQPad which does a great job in terms of writing linq code where you can also see...
How do I do a Case WHEN in Linq to SQL (vb.net please).
In SQL it would be like this:
SELECT
CASE
WHEN condition THEN trueresult
[...n]
[ELSE elseresult]
END
How would I do this in Linq to SQL?
...
Here's a simple method with a foreach loop:
IEnumerable<XElement> FieldsToXElements(object instance)
{
var fieldElements = new List<XElement>();
foreach (var field in instance.GetType().GetFields(instance))
{
fieldElements.Add(new XElement(field.Name, field.GetValue(instance)));
}
return fieldElements;
}
...