linq-to-sql

Generating entity class files from table schema

I am using LINQ to SQL with C#. Is there a method through which we can generate entity class files from the table schema? By dragging tables onto the graphical designer classes are generated but they are not the real class files(i mean actual files with the extension cs). I am aware of that we can code the class files first and then cr...

Mapping collection of strings with Entity Framework or Linq to SQL

I would like to know if it is possible to map a 1-many database relationship as an array of primitives on the parent object class. For example, say I have a database as follows: TABLE: PERSON ID - int TABLE: PERSON_EMAIL_ADDRESSES PERSON_ID - int EMAIL_ADDRESS - string For my Person class, I'd like to have the following:...

LINQ to SQL not updating database records in MVC 2 application

Hello :) Using MVC 2 I have been trying to make this record store project. Creating records work but updating them doesn't. No exceptions are thrown either. I examined getchangeset() right before submitchanges() it shows all zeros. Thanks for your reading and you help :) The Edit view: <% using (Html.BeginForm("Edit", "Song")) { %> ...

Optimising Lamda Linq to SQL query with OrderBy

I have the following lamda expression: IEnumerable<Order> query = _ordersRepository.GetAllByFilter( o => o.OrderStatus.OrderByDescending(os => os.Status.Date).First() .Status.StatusType.DisplayName != "Completed" || o.OrderStatus.OrderByDescending...

How to use submitChanges if i create programmatic control to collect data?

i created my Form programaticall using System.Reflaction. i want to add database with SubmitChanges. i will get data from whole txtbox and using any loop to fill Entity property. And than Submitchanges. public static void Save( PlaceHolder Holder) { if (Holder.Controls.Count > 0) { fo...

How to add values listDictonary to sql with linqtosql?

i can this with ado.net but i want to use it linqtosql foreach (string ky in ld.Keys) { cmd.Parameters.AddWithValue(ky, ld[ky]); } public bool AccessProcess(string sp, ListDictionary ld, CommandType cmdType) { SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["conn"].ToString()); SqlCommand cmd = new SqlC...

Can Linq to Sql (L2S) update a database when a class/property is added to the DBML?

I have a small L2S database that was generated with the L2S CreateDatabase command. When I add a class or property to the DBML, the database is not updated automatically. I get errors like "Table not found" at runtime. Is there a way to add new tables and columns to a database? ...

Asp.net MVC validation for non-strings

I originally built my site in MVC 1.0 using the NerdDinner tutorial as a basic outline. Many of the early design decisions were made simply b/c "that's how NerdDinner did it" Since then, it has really grown and was converted to 2.0. My validation still works the way NerdDinner did it and is very minimal, so although I've read about ot...

Open row in DataGridView to Edit, DGV has SQL Backend in C#

OK, so i've got a DataGridView for some Project Management Software, i want to be able to double click a row it opens a form and fills in the fields and combo boxes with the relvant data, so that i can change what ever needs to be changed. In this case the most important thing is changing the Status. As in the Project Management Software...

Determine the type of Object to use to store a Linq Query

I am using VB .Net for this, so I don't have access to var or this would be a simple matter. Right now my query is as follows Dim errors As IOrderedQueryable(Of IGrouping(Of String, RSError)) = (From e In db.RSErrors Where e.UserID = "msarchet" ...

LINQ to SQL. Cascade delete sumulation

I have many-to-many relation between persons and addresses Person { Id, ... } Address { Id, ... } Address2Person { Id, PersonId, AddressId } DBML-generated classes looks like (there are PK and FK on diagram): class Person { Id, Address2Person } class Address2Person { Id, Person, PersonId, Address, AddressId } class Address { ...

Handling multiple updates to the same row at the same time in an asp.net mvc website using linq to sql

I am using linq to sql as ORM for my asp.net mvc website. I dont know how will linq to sql behave in the following situation. Suppose one of the action from a active session, modifies a row of a table and before saving the changes to the database, I mean before calling _db.SubmitChanges() another action from some other session tries to...

LINQ TO SQL - Skip/Take not working as expected.

I've got an IQueryable repository (admittedly this is the first time I've tried this) and I can't seem to get it to pull the correct data using Skip(1).Take(1) Here's the repository Public Function GetActivity() As IQueryable(Of ActivityLog) Implements IActivityLogRepository.GetActivity Dim activity = (From a In dc.Activity...

IQueryable Linq To SQL with multiple operators

I'm creating a repository and service layer in my app, and my repo has a very simple function Public Function GetRegions() As IQueryable(Of Region) Implements IRegionRepository.GetRegions Dim region = (From r In dc.Regions Select r) Return region.AsQueryable End Function Now in my Service layer...

Loop structure to save data in CONTEXT with addwithValue method?

Hi.. my linq knowledge is ok. i need only a loop or any other method to accomplish ado.net method :(LOOK PLEASE BOLD CODES) public bool AccessProcess(string sp, ListDictionary ld, CommandType cmdType) { SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["conn"].ToString()); SqlCommand cmd = new SqlCommand(s...

Convert Linq To Sql with JOIN to IQueryable select.

I have a function called GetUserByOpenId I don't want to be using this function at all Public Function GetUserByOpenID(ByVal claimedidentifier As String) As User Implements IUserRepository.GetUserByOpenID Dim user = (From u In dc.Users Join o In dc.OpenIDs On u.ID Equals o.UserID Where...

What's wrong with my code inner join in linq to sql?

What's wrong with my code? For the Employee table and the table Project are underlined in red ... Thanks in advance! DataContext db = new projfuncionarioDataContext(); var query = from p in db.Funcionario join c in db.Projeto on p.Cdfunc equals c.Cdfunc select new {...

Search uniqueidentifier value in SQL Server 2008 table

I have a table in SQL Server 2008 with uniqueidentifier field. In my application (C#, WPF) I have a textbox which intended for search some data by GUID, user can enter guid by typing, ctrl+v, etc, so he/she can make an error. What is the best and fastest approach to make a search by this field using linq2sql ignoring whitespaces, "-".....

Best custom dynamic grid for MVC

.Net MVC application also running Linq-to-SQL. I have seen many articles on grids that will operate in this environment but none that will capture data - all simply display and sort/order. I need to dynamically add project codes as columns and have days of the week as rows. The individual cells will contain hours worked - yup this is ...

what ADO.Net version is currenlty used in ASP.net MVC 2?

Hi, Current ASP.Net MVC 2 uses Linq to SQL or Linq to entites? i am using VS 2008. Cheers ...