Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,824 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am trying to add new record to database by linq only if is a new row from a datagrid wpf.
You could use is. Here is a sample example
public interface IItemType
{
int x { get; set; }
}
public class OldItem : IItemType
{
public int x { get; set; }
}
public class NewItem : IItemType
{
public int x { get; set; }
}
for(int i=0; i<10;i++)
{
if(i % 2 ==0)
{
list.Add(new OldItem { x = i });
}
else
{
list.Add(new NewItem { x = i });
}
}
var newItems = list.Where(itm => itm is NewItem).ToList();
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/is