I need to find the highest value from the database that satisfies a certain formatting convention. Specifically, I would like to fund the highest value that looks like
EU999999 ('9' being any digit)
select max(col) will return something like 'EUZ...' for instance that I want to exclude.
The following query does the trick, but I can...
I am currently working on a C# windows form with linq-to-sql that selects a row from a SQL table and then allows the user to edit the fields in that row. This form will be used by multiple users at a time and I would like to have it so when someone has selected a row and is currently entering data in the form (with which the row will be...
I have 1 to many relationship with the following tables - Person and Email. When using linq to sql and ASP.Net MVC, I'd like to show the first email or an empty string in my Person view using code like this:
<%= Html.Encode(Model.Emails.FirstOrDefault().EmailAddress) %>
In cases where there are no email rows, I receive a NullReference...
I know there are several questions like this on here already, but I can't find one that relates to my problem.
I've got an SP declared like this:
CREATE PROC [dbo].[SomeProc]
(
@param1 VARCHAR(255)
, @param2 INT
, @param3 VARCHAR(8)
)
When I add the Stored Procedure to the Data Model it generates the following signature:
int S...
If I have say for example 100,000 rows to insert/update/delete, and this number will grow constantly. Which of the following is the best approach, or does it not make any difference.
The PeopleRepository AddPeople implementation
public void AddPeople(IEnumerable i)
{
_Database.people.InsertAllOnSubmit(i);
}
The PeopleRepository A...
Hi,
I want to use Linq2Sql as the data source for my Crystal reports. I have all my data in my domain objects in the form of Lists. The problem is all my domain model resides in a different namespace in the form of a .dll. And when i try to assign a data source for my report in Database Expert window, under .NET Objects, i can only see ...
My problem is pretty simple. Lets say I have a dropdown with users.
in the database i have 3 fields for my user table:
user_id
user_name
user_firstname
in my MVC app i want to link those users to projects. so thats why i want the dropdown.
now, i want to have a selectlist, with the ID as the value, and the firstname AND lastname t...
IQueryable<SomeType> collection = GetCollection();
foreach (var c in collection)
{
//do some complex checking that can't be embedded in a query
//based on results from prev line we want to discard the 'c' object
}
//here I only want the results of collection - the discarded objects
So with that simple code what is the best way...
Is is possible to do this in SQL in Linq to SQL?
Select field from table where date between '2010-01-01' and '2010-01-31';
I realize I could do:
where (monthBeginDate < a.StopDateActual && a.StopDateActual < monthEndDate)
But I was curious if I could do the former. I have a bad habit of screwing up the less than and greater than on...
Let's say I have a Person table with a FirstName and LastName column.
I extended the Person LINQ entity class with a get property "FullName", that concatenates the first and last names.
A LINQ query like:
from person...
select fullName
where id = x
generates SQL selecting all Patient columns, since FullName is evaluated after f...
My database field (sql server 2005) is defined with numeric(15,2).
The LINQ 2 SQL generated property is
[Column(Storage="_My_Property_Name", DbType="Decimal(15,2)", UpdateCheck=UpdateCheck.Never)]
public System.Nullable<decimal> My_Property_Name
{
get
{
return this._My_Property_Name;
}
...
Is there the ability for doing this work? How can I do this work?
...
Hello,
I need to generate a report for a system which has a whole bunch of quotes, some of which have been accepted (a receipt has been created), and some of those accepted have since been cancelled. I need a list, per user, with the following things:
-The amount of quotes made
-The amount of accepted quotes
-The total price of accepte...
I am new to LINQ to SQL, but have done a lot of database development in the past.
The software I just started working on uses:
// MyDataContext is a sub class of DataContext, that is generated with SqlMetal
MyDataContext db = new MyDataContext (connectionString);
db.CreateDatabase();
to create the database when it is first run.
I ne...
Linq to SQL, in the dbml designer (or otherwise)
I have 3 tables:
Orders, Deliveries and EmailTemplates.
Orders have many Deliveries, and Orders and Deliveries have a status (int) field.
EmailTemplates have a status they apply to and a bool IsForDeliveries field.
I have Linq to sql associations for Order->EmailTemplate on order.st...
When using DataContext.CreateDatabase() to create a database, I wish to stop Linq To Sql creating a clustered index on the primary key of a table.
This is because I wish to create a normal index for the primary key, as I need the clustered index to spread up range queries on a date field.
...
I have data access object that have been generated by SqlMetal, however the database is created by running a sql script.
Is there an easy way to verify that all table and columns names and type matches the attributes on the classes that SqlMetal created?
...
I have Created a table like
CREATE TABLE [dbo].[tab1](
[Id] [int] NOT NULL,
[Name] [varchar](100) NOT NULL,
[Meta] [xml] NULL,
CONSTRAINT [PK_tab1] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ...
I have a table with hit statistics for some items in another table.
This table is defined like this
ID (Primary key)
ItemId (Foreign key)
Date
Hits
Giving me have a record pr. item pr day.
The database is used in a multithreaded environment, so two users might make the first hit at the same time causing two records to be created, w...
I have a form in which we are showing customer records in a grid.User clicks a row, and in a new form record is shown.After editing some values, user may click cancel. if so, in grid we need to return to original values.
How can I restore the original state of the entity.We are using linq-to-sql, and grid is bounded to List.One way I ...