I have a sql stored procedure that uses isnull in the order by clause to order items by the latest reply date, or if that is null, by the posting date:
Example:
ORDER BY isnull(rtb.LatestReplyDate,CB_TOPIC_DATE_POSTED) DESC
I am trying to get that to work in the orderby clause of a linqdatasource, to no avail yet:
Example:
...
I have two tables customers, pay and want to implement a gridview in silverlight with the outcome of the relationship of these two tables, the query is as follows
SELECT Pa.Tipo_Pagare, Pa.Pagare, Pa.Rut, Cli.Nombre
FROM Cred_Crexsa.dbo.Pagare AS Pa INNER JOIN
Cred_Crexsa.dbo.Clientes AS Cli ON Pa.Rut = Cli...
When assigning a linq selection to an implicitly typed local variable "var" i receive the
following error.
Error :Cannot assign method group to an implicitly-typed local variable
at
root : var mailgroup = emails.Where(p =>IsValidFormat(p.Value)).Select;
Dictionary of elements
Dictionary<int, string> emails = new Dictionary...
Hi Experts,
I am working on a project Where I have multiple reposetories to fetch data from
differnt tables. All my repositories are independent, they create new dataContext, Add row to table and apply submit changes command. Now if in my service, there is a situation where I have to insert data into multiple tables, but it should happ...
I have a master list of colors:
List<string> completeList = new List<string>{"red", "blue", "green", "purple"};
I'm passing in a List of existing colors of a product
List<string> actualColors = new List<string>{"blue", "red", "green"};
How do I get a list back that is in the order of the completeList? (red,blue,green)
...
Hey, I am trying to create an Expression<Func<T, bool>> in which a string property is converted/cast to a DateTimeOffset so that DateTimeOffset operations can be performed on it.
We are using Linq2SQL as our data provider, which does support converting strings to the SQL equivalent of DateTimeOffset. Ideally I want the expression to be...
How to convert XML Elements to of type Person ?
Elements :
XElement persons = XElement.Parse(
@"<persons>
<person>
<id>10001</id>
<name> Daniel </name>
</person>
<person>
<id>10002</id> ...
I want to find a section of xml based on a criteria so I’m using linq to XML. Unfortunately the result is always null so I guess I’ve done something wrong. Shown below is an example of the XML I’m parsing.
<Stuff>
<ItemsA />
<ItemsB />
<ItemsC>
<Item xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacont...
Is there an equivalent to F#'s List.map function in C#? i.e. apply a function to each element in the list and return a new list containing the results.
Something like:
public static IEnumerable<TResult> Map<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> funky)
{
foreach (TSource element in source)
...
i created a loop up to 100 to insert any data in db.
but when i close my browser I hope it stops but it in background it continues looping and filling my db. how can I stop it?
thanks
...
How can i programatically push an array of strings into generic Stack ?
string array
string[] array=new string[]{"Liza","Ana","Sandra","Diya"};
Stack Setup
public class stack<T>
{
private int index;
List<T> list;
public stack()
{
list = new List<T>();
index=-1;
}
public void Push(T obj...
I wish to get the lastest written files from a directory and their extentions.
An example of what file that could exist in the directory (with their creation dates):
2009-10-20T07:00:00.000 filename1.mp4
2009-10-20T07:00:01.000 filename1_0.mp4
2009-10-20T07:00:02.000 filename1_1.mp4
2009-10-20T07:00:00.000 filename1.wmv
2009-10-20T07:1...
I have a Linq object, and I want to make changes to it and save it, like so:
public void DoSomething(MyClass obj) {
obj.MyProperty = "Changed!";
MyDataContext dc = new MyDataContext();
dc.GetTable<MyClass>().Attach(dc, true); // throws exception
dc.SubmitChanges();
}
The exception is:
System.InvalidOperationException: An enti...
Hi
This following code example is borrowed from MSDN here. I am not getting query.CopyToDataTable() available in my code. (see the commented line in my following code).
public static bool SetPhysicianAsNotonServer(DataTable dt)
{
DataTable dtPhysicianServer = dt;
DataTable dtPhysicianClient = GetPhysi...
Mapping-File:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="DaVinci"
namespace="DaVinci.Domain">
<class name="Waehrungskurs" table="WAEHRUNGSKURSE">
<id name="Id" column="ID">
<generator class="native" />
</id>
<property name="ISO...
I am using the .Skip and .Take methods with Entity Framework. The .Skip call is being honored when generating the SQL. The .Take is not. This code:
public IList<DocPullRun> GetDocRunsPaginated(int startRowIndex, int maximumRows) {
Logger.Debug("GetDocRunsPaginated: startRowIndex: {0}, maximumRows: {1}", startRowIndex...
I'm having trouble converting a C# Linq statement to VB.NET. I need the following statement converted. I am getting hung up on the i.Sum(v=>v) part.
from p in Products
from u in Users
let i = (from op in OrderProducts
where op.Order.User == u && op.Product == p
select op.ProductQty)
let quant = i.Count() == 0 ? 0 :...
Hello,
Is it possible to sort a MembershipUserCollection by IsApproved and then Comment without modifying the Stored Procedure? Can Linq do this?
Thanks!
...
This is easy to do in SQL and I'm having a very hard time achieving this using Linq to SQL. I have two entities setup, Project and ProjectsbyUser:
[Table(Name = "Projects")]
public class Project
{
[Column(IsPrimaryKey = true, IsDbGenerated = true, Name="Job")]
public string ProjectId { get; set; }
[Column(Name = "Descript...
hi there.
I want to searching in a xml file. this is my linq sentece.
string _sSemptom = "try";
XElement xe = from c in xdSemptom.Elements().Elements().Elements()
.Elements().Attributes("Isim")
where c.Value.Length >= _sSemptom.Length &&
c.Value.Contains(_sSemptom)
...