linq-to-sql

LINQ to SQL query help (string contains any string in string array)

Hi, I've been tearing my hair out with this one. I've got an array of search terms and I'm trying to do a LINQ to SQL query to search field values against each item in the array. I got this far.. var searchResults = from x in SDC.Staff_Persons where staffTermArray.Any(pinq => x.Forename.Contains(pinq)) || staffTermArr...

Use fLinq to persist?

I don't see a lot of examples on how to persist with linq/flinq- I may ultimately write a proc to dowhat I need it to, however the 1->* relationship between tableA and tableC makes that tricky. Can you persist with flinq? Is there a example published somewhere I could follow? Below is what I have tried (or rather the most logical vari...

Combine Linq2SQL with custom SQL.

From a custom SQL query I'd like to get an IQueryable (I have my reasons): Something like: IQueryable<Client> query = Foo<Client>("SELECT * FROM Clients WHERE ..."); query.Where(e => e.Active==true).Skip(10).Take(10); //etc. Is there any way to implement Foo? I found ExecuteQuery<T>(...).AsQueryable(), but that doesn't work as it ...

C# WPF Linq to SQL Databinding

Hi, i have generated a Linq to Sql class which looks like this. so i have 3 querys which gets my data. private IQueryable<Gesellschaft> loadedGesellschaft; private IQueryable<Anschrift> loadedGesellschaftAnschrift; private IQueryable<Email> loadedGesellschaftEmail; private lgDataContext completeGesellschaft; private void Button_Cl...

PLINQO / LINQ-To-SQL - Generated Entity Self Save Method?

Hi I'm trying to create a basic data model / layer The idea is to have: Task task = TaskRepository.GetTask(2); task.Description = "The task has changed"; task.Save(); Is this possible? I've tried the code below Note: The TaskRepository.GetTask() methods detaches the Task entity. I'd expect this to work, any ideas why it doesnt? T...

How can I use linqTOsql to efficiently get nested lists?

I have three tables that I would like to query: Streams, Entries, and FieldInstances. I'm wanting to get a list of entries inside a stream. A Stream could be a blog or a page etc. and entry is the actual instance of the stream ie: "stream:Page entry:Welcome" or "stream:blog entry:News about somthing". The thing is, each entry has custo...

Determine progress while evaluating LINQ query

My C# program has long executed LINQ query running against MS SQL Server database. I'd like to show user a progress while executing the query. Is there any way to understand LINQ execution progress? Of course I can show undeterminate progress, but if possible, I'd prefer determinate. ...

Mapping interface instead of class to Database Table

Is this possible? how? As far as you know to mapping a class to db table we should be use TableAttribute(Name="tableName") attribute, so we can't use attributes on interfaces. If i don't use this attribute, "The type 'interfaceName' is not mapped as a Table." showed. ...

LINQ to SQL generates negative conditions in WHERE clause

I am using LINQ to SQL to retrieve data, using boolean conditions (BIT columns in SQL). My LINQ query looks something like this: var query = from r in db.Requests select r; query = query.Where(r => r.Completed == someBooleanVal); query = query.Where(r => r.Cancelled == someOtherBool); return query.ToList(); The 'Where()...

Adding a custom function in the linq statement

Hi folksI want to search in keywords field like search key in the set. e.g. my key is "Wing" keywords is "Wing Dress Others" with spaces what should I write instead it ? Error : Method 'Boolean Compare(System.String, System.String)' has no supported translation to SQL. protected void Page_Load(object sender, EventArgs e) { if (Requ...

Linq compare before inserting to database

HI, I have Ling Table with MyObject. It has got fields: Id Number Name There is a method that adds ne MyObject to Database. In partial class MyOBject Im implementing OnValidate method. I need to check if there is already a row with such number and name. The problem is where this values are nulls (for this example both can be) var r...

DLinq morphed into which one -- Linq to SQL or the Entity Framework?

What happened to Dlinq? I heard a few years ago that it was abandoned. Was some of its code used to create Linq to SQL or the ADO.NET Entity Framework? Which one? In other words, which of the two latter technologies are a new avatar of the old DLinq? I am learning ADO.NET Entity Framework and since I am just starting out, I believe th...

"String or binary data would be truncated." linq exception, cant find which field has exceeded max length

String or binary data would be truncated. linq exception, cant find which field has exceeded max length. i have around 350 fields. i checked each and every textbox maxlength with database field maxlength, everything seems to be correct, but i still get the exception. please help ...

Convert Expression trees

let there be : Expression<Func<Message, bool>> exp1 = x => x.mesID == 1; Expression<Func<MessageDTO, bool>> exp2 = x => x.mesID == 1; now i need to pass exp1 to _db.Messages.where(exp1); problem is i only have exp2, i need to convert the type to Message , All properties are the same ! now i do this : var par = Expression.Parameter...

sqlmetal fails to extract udf with full-text

Error message: Warning : SQM1014: Unable to extract function 'dbo.ProductFamilyIndex_EN' from SqlServer. Null or empty full-text predicate. function defined as: CREATE FUNCTION [dbo].[ProductFamilyIndex_EN] ( @topn int, @keywords nvarchar(4000) ) RETURNS TABLE AS RETURN ( select top (@topn) ProductFamilyID from ...

C# Reflection on Nested Properties of a Class

I wanted to know how can I get the Value of Property in C#, but this property is of another Type. public class Customer { public string Name {get; set;} public string Lastname {get; set;} public CustomerAddress Address {get; set;} } So I'm able to get the property values of Name and LastName but I quite don't get how to get t...

Linq to SQL InsertOnSubmit for multiple objects

I have a problem with Linq to SQL InsertOnSubmit, which only seems to work for the first item in a table. For example with the following: var noteDetail1 = new NoteDetail() { Title = "Test Note Title 1", NoteText = "Test note" }; var waiverDetail1 = new WaiverDetail() { Title = "Test Waiver Title 1", NoteText = "Test waiver details tex...

Domain Design class decisions

I am creating a simple web site to get more familiar with MVC 2.0. I've been doing web forms since 1.0 and getting ready to start a major overhaul of a web forms site to MVC. So want to build a smaller app to work out the learning curve. So I'm going to build a time tracking application. I'm using ASP.NET MVC 2.0 and LINQ to SQL. I pl...

Will my SQL Connection remain open after my dictionary is populated

In the code sample below, will my data context connection stay open once the ListOfLists method is completed? Do I need to explicitly close it, or will it stay open and be available for other methods. public static Dictionary<int, string > ListOfLists() { try { ListDataDataContext db = ne...

How to convert this dynamic sql script into LinqToSql?

How to convert this dynamic sql script into LinqToSql? -- Create sample table Create Table TEST (DATES Varchar(6), EMPNO Varchar(5), STYPE Varchar(1), AMOUNT Int) -- Insert sample data Insert TEST Select '200605', '02436', 'A', 5 Union All Select '200605', '02436', 'B', 3 Union All Select '200605', '02436'...