Hi all,
I am trying to use LINQ to query a list of objects wherever appropriate. Currently I am stuck on the syntax of a nested query which I hope you can help me with.
Classes:
public class FooType
{
public int Id { get; set; }
public IList<Foo> Foos { get; set; }
}
public class Foo
{
public int FooTypeId { get; set; ...
i have following tables
T1
==== ======
ID Desc
==== ======
1 t1
2 t2
3 t3
4 t4
T2
===== ======= ========
ID T1ID PT1ID
===== ====== =========
1 2 1
2 3 2
In T2 both T1ID and PT1ID are foreign key for T1. In my output...
Hi every one,
I have the following SQL query:
SELECT C.ID, C.Name FROM Category C JOIN Layout L ON C.ID = L.CategoryID
JOIN Position P ON L.PositionID LIKE '%' + CAST(P.ID AS VARCHAR) + '%'
WHERE P.Code = 'TopMenu'
and following data
Position:
ID Code
1 TopMenu
2 BottomMenu
Category
ID Name
1 Home
2...
Hi
Am trying to get linq to call a stored procedure. I know this is usually rather simple, but in this case i am using my own Custom Entity Classes and I am at a dead end.
the link below will show you how I have my OM setup
example
does any one know how you can call a stored procedure from your own Custom Entity Class?
EDIT:
Forg...
In my LINQ to SQL generated db class, I have a table with a foreign key reference to a field that has useful date information. A query might look something like this:
var query = from a in db.TableA
join b in TableB on a.FK_B_Id equals b.Id
where b.Date.Value <= DateTime.Today
select a;
...or more s...
I was looking at a co-workers Linq query, shown below (the query executes correctly):
from ea in EquipmentApplication
join erl in EquipmentRoutingLocation on ea.EquipmentID equals erl.EquipmentID into erlWithNulls
from erlAll in erlWithNulls.DefaultIfEmpty()
join rl in RoutingLocation on erlAll.RoutingLocationID equals rl.RoutingLocati...
I would like to design my application to do the following:
1. Send a LINQ query from a client to some WCF service on some server
2. That server receives that LINQ query and performs a linq-to-object search
3. The server then returns back the results.
Is this possible? If so how? I'm unable to find any tutorials on this topic.
Note: I d...
I'm trying to write a Linq query which fetches all users whose first or last name begins with at least one string in a list of strings. This is used for auto-completion of recipients in a messaging system.
This was my first naive attempt:
var users = UserRepository.ALL()
foreach (var part in new [] { 'Ha', 'Ho', 'He' })
{
string pa...
I posted up part of some code the other day but in doing so caused more confusion. This is my code.
if ( HttpContext.Current.Session != null )
{
if ( HttpContext.Current.Session[ "CurrentLabourTransactions" ] != null )
{
Collection<JCTransLabour> oJCTransLabours = null;
...
Hi,
In my project I create the Linqto-SQL Classes using SqlMetal. The problem with this is that SqlMetal doesnt appear to create a parameterless constructor. I've always got round this because in my code I can always get the default connectionstring name and pass it to the constructor, however now I am being forced to use a linqdatasour...
I am trying to do an update in Linq.
public myFunc(MyItem newItem)
{
using(var db = new myDataContext())
{
var item = (from o in db.myTable where o.id == myId select o).First();
item = newItem;
db.SubmitAllChanges();
}
}
This doesn't update the object, I guess item = newItem changes item to refer to the other. If ...
i have a split front-end and back-end access database. i am planning to move it into sql server. the front end will be c# linq to sql.
question:
is it going to be possible to have multiple users use this c# front end and for example be able to edit a table at the same time? you know that ms-access you can design a form with a table on i...
public static int SafeCount<T>(this IList list)
{
return list != null ? list.Count : 0;
}
What I want to ask is what should I call this method? SafeCount? NullSafeCount?
Can you come up with something more short yet non-ambigous?
...
I'm trying to get this LINQ to work but fails with the error.
Cannot convert lambda expression to type 'System.Collections.Generic.IEqualityComparer' because it is not a delegate type
Basically I have IEnumerable and I'm trying to group the data, as in:
string sql = @"SELECT [t0].[Contact_Account] AS [Contact], [t0].[Work_Phone] AS [...
I have this property, which is working fine:
public IEnumerable<IGrouping<MessageType, Message>> MessageGroups
{
get
{
return
(from msg in _messages
orderby msg.Type descending
group msg by msg.Type);
}
}
However, it's causing me to have to repeat the ugly-looking IEnumer...
I am trying to populate a tree view based on a list of staff from various deparments (lstStaff).
public class Staff
{
public int StaffID { get; set; }
public string StaffName { get; set; }
public int DeptID { get; set; }
public string DepartmentName { get; set; }
}
The result should be like this:
Department A
John
D...
Hi All,
I am retrieving data from sql database. I want to split the records and binding it in three different grids. Everything is working fine before applying paging. I am getting The data source does not support server-side data paging. error
Code:
DataTable StoreDisplayTypeList = storeDisplayBL.GetStoreDisplayDetails();
...
I have a collection as follows
Private _bankRates As Dictionary(Of RateSourceBank.Key, RateSourceBank)
Where RateSourceBank.Key is simply
Public Class Key
Public RateType As String
Public EffectiveDate As DateTime
End Class
How can I retrieve a subset of _bankRates that have more than one EffectiveDate per RateType?
Unf...
There is an existing sproc that for the purposes of this experiment I do not want to change. It is currently called via a non-linq method like a sqlcommand and takes an xml parameter.
Current implementation (Non-Linq)
An xml fragment eg:
"<someTag>1</someTag><someTag>2</someTag>"
is passed to the sproc as a string. Notice that ...
joining tables on two columns is easy
from t1 in table1
join t2 in table2
on new { KEY1 = t1.TB1Key1, KEY2 = t1.TB1Key2 }
equals new { KEY1 = t2.TB2Key1, KEY2 = t2.TB2Key2 }
select new { t1 , t2}
but what if i want an OR condition?
the SQL will look something like this:
select * from table1 t1
inner join table2 t2
on t1.TB1...