How would you remove "NULL rows" from a String array using LINQ?
Take this structure (String[,]):
"Hello", "World", "Foo", "Bar"
null, null, null, null
null, null, null, null
"Hello", "World", "Foo", "Bar"
"Hello", "World", "Foo", "Bar"
null, null, "Foo", "Bar"
The two rows after the first row should be removed. T...
I have two tables tblActionLog and tblLoginLog.
This is tblActionLog:
tblActionLog
------------
ID (int)
Happened (DateTime)
...etc.
This is tblLoginLog:
tblLoginLog
-----------
ID (int)
LoginDate (DateTime)
...etc.
Now I want to have a GridView with information from both of these tables interleaved in eachother so that their sepa...
Using Linq-to-Sql:
MyClass obj;
...
// need to delete this object
dataContext.GetTable(obj.GetType()).DeleteOnSubmit(obj);
BUT
I don't know whether or not obj has been attached to the data context. And if it hasn't, that last call to DeleteOnSubmit throws an exception.
There has to be an easy way of telling whether obj is attached ...
Let's say I have the following code.
var numberToGetTo = 60;
var list = new[] {10, 20, 30, 40, 50};
I want to be able to return 50 & 10 from list to = 60.
If the numberToGetTo was 100 I would want to return 50, 50.
If the numberToGetTo was 85 I would want to return 50, 40.
I want to return the least amount of numbers from the list...
Hi all,
I have a simple XElement object
XElement xml = new XElement("XML",
new XElement ("TOKEN",Session["Token"]),
new XElement("ALL_INCLUSIVE", "0"),
new XElement("BEACH", "0"),
new XElement("DEST_DEP", ddlDest.SelectedVa...
I have started using Subsonic for a side project and have been loving using it. Simply a blast. I started off wanting to use the LINQ T4 Templates but have since switched to the ActiveRecord templates due to testability. It is very clear how to write unit tests using the active record templates but for the LINQ templates there is no clea...
Say I have a class with 2 properties
class TestClass
{
public int propertyOne {get;set;}
public List<int> propertyTwo {get; private set;}
public TestClass()
{
propertyTwo = new List<int>();
}
}
Using linq, I am trying to create a list of TestClass as follows:
var results = from x in MyOtherClass
...
I am trying to do this on a method which is basically a mapper - maps old categories List to a new List. The OldCategory has fewer properties.
return categories = from c in oldCategories select new Category
{
CategoryName = c.CategoryName,
Id = c.CategoryId,
Teams = CombineTeam(c.Team, coreTeam)
};
Why can't I use CombineTeam met...
I have an loaded an XML document with the following structure:
<?xml version="1.0" encoding="UTF-8" ?>
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<sheetData>
<row r="1" spans="1:2">
<c r="A1" t="s">
<v>...
Given a datatable, I wish to output an IEnumerable type (dictionary(of T) would be perfect, otherwise a datatable would be acceptable) that provides an aggregation of the data within the datatable.
In SQL I would write the query as such:
select groupByColumn, sum(someNumber) from myTable group by groupByColumn
In VB.NET the closest ...
Is there a way to increase the sql timeout in subsonic 3 when using LINQ?
Example code
var db = new Edumatic3DB();
var treeNodes = from tn in db.TreeNodes
join ts in db.TreeStructures
on tn.TreeStructureId equals ts.TreeStructureId
where ts.LeftValue > treeStructure.LeftValu...
Hi,
I'm writing a simple LINQ to XML query. As often, the some elements might be missing for some nodes in the XML document. To solve this issue, I tried to use nullable types and the coalesce operator as proposed by Scott Guthrie. Whan effect that I noticed is that casting elements to (string?) dit not work while casting to (int?) work...
Hello,
I'm using the code below for my search logic, basically, it evaluates a field when there's an input on the corresponding textbox or dropdown, my problem is that the code is only for exact matches, what's the best way to implement also a .Contains() search, or a search which implement an SQL LIKE search?
private void btnSearch_...
Hi all,
I have the following code, I want to use Linq, any possible ??
I have one list of users, and I need generate other list.
any help ? thanks in advanced, greetings
SortedList<ClaveUsuarioPersonal, UsuarioRe> users = new SortedList<ClaveUsuarioPersonal, UsuarioRe>();
if (this.UsuarioRe.UsuarioSar != null)
...
I Want to print out the number of tables in a Typed dataset along with the number of fields associated with each table and the key fields { primary,foreign}. How to get this information using LINQ?
...
Hi,
I am using .NET 3.5. What method of the Array class is best for returning a empty index in an array (which can then be used for populating). The Single/SingleOrDefault() methods look good, but if there is more than one empty slot, I want the first with the lowest index.
EDIT: This is pretty easy with a loop, but I am looking at way...
If I have a customers and orders relationship in my Linq or EF model, at the WCF service layer I can add an order to the customer by calling
Customer.Orders.Add(customer);
When I access my customer object on the client, and want to add an order, there is no Add method, and the Orders propery is an array. Is there any way I can work w...
Hi experts,
I have a legacy VB6 app which I am rewriting in .Net. I have not used an ORM package before (being the old fashioned type who likes to know what SQL is being used), but I have seen good reports of NNibernate and I am tempted to use it for this project. I just want to check I won't be shooting myself in the foot.
Because my ...
We have this very strange issue on LINQ to SQL Code.
Consider this code snippet :
var wissen = db.Table.Where(f => f.Name == somevalue);
db.Table.DeleteAllOnSubmit(wissen);
db.SubmitChanges();
This works as expected on our dev servers, but when we are deploying this to our production server it doesn't give any errors but it doesn't ...
I've got the following sql statement and need to know how to write it in linq, but i can't figure out how to write the multiple inner joins
SELECT Zugehörigkeiten.PK_Dept_ID
FROM mitarbeiter
INNER JOIN (abteilungen
INNER JOIN Zugehoerigkeiten
ON abteilungen.PK_Dept_ID = Zugehoerigkeiten.PK_Dept_ID)
ON mitarbeiter...