If I have an object that lazy loads an association with very large objects, is there a way I can do processing at the time the lazy load occurs? I thought I could use AssociateWith or LoadWith from DataLoadOptions, but there are very, very specific restrictions on what you can do in those. Basically I need to be notified when an EntitySe...
I'm going nuts over what should be a very simple situation. In an ASP.NET MVC 2 app (not that I think this matters), I have an edit action which takes a very small entity and makes a few changes. The key portion (outside of error handling/security) looks like this:
Todo t = Repository.GetTodoByID(todoID);
UpdateModel(t);
Repository.Sav...
I need to filter out parent by property value of child collection.
I am doing something like this:
var results = (from c in db.Customers where
c.Orders.Any(o => o.Status = (int)Status.Ordered)
select c;
It's fine but now I need to filter by 2 values, i.e. take all parent records that have any chilren records that have BOTH v...
I have the following Iqueryable method to show details of a singl material,
public IQueryable<Materials> GetMaterial(int id)
{
return from m in db.Materials
join Mt in db.MeasurementTypes on m.MeasurementTypeId equals Mt.Id
where m.Mat_id equals id
select new Materials()
{
...
I am using LINQ to SQL and seeing my CPU Usage sky rocketting. See below screenshot. I have three questions
What can I do to reduce this CPU Usage. I have done profiling and basically removed everything. Will making every LINQ to SQL statement into a compiled query help?
I also find that even with compiled queries simple statements li...
I am creating an mssql database table, "Orders", that will contain a varchar(50) field, "Value" containing a string that represents a slightly complex data type, "OrderValue".
I am using a linqtosql datacontext class, which automatically types the "Value" column as a string.
I gave the "OrderValue" class implicit conversion operators t...
i want to pass parameter to linq query...
public IEnumerable GetPhotos()
{
PhotoDBDataContext db = new PhotoDBDataContext();
var query = from p in db.Photos
orderby p.PhotoId descending
select new { p.Album, p.AlbumId, p.Description, p.Photographer,
p.PhotographerId, p...
I am having a weird Situation with my DataConext.
All My code is in C#
I have a DLL project for my data access layer and business Layer which and Winforms project for my UI layer.
My Data access Layer's Namespace is xxx.Data this is where have my xxx.dbml I also have xxx.Data.BusinessObjects name space of course for my business object i...
I'm writing a forum in ASP.NET. I have a table of posts. How can I assign a post to a user? If I had a normal User table, I'd just creating a new field in the post table "UserId" and creating an assocation in the Linq to Sql designer. But now? Should I include the aspnet_Users in the designer?
Thanks.
...
I have a Table called Address. I have a Trigger for insert on that table that does some spacial calculations on the address that determines what neighborhood boundaries it is in.
address = new Address
{
Street = this.Street,
City = this.City,
State = this.State,
...
Hi, all my entities have a common property which specifies the company they belong to, I would like to set this property in a method in my datacontext but I do not want to use the partial methods for each of the entity types that the datacontext provides, is there a method that receives any entity that is inserted throught the datacontex...
Hi,
Is there any way to cache LINQ to SQL queries by looking at the parameters that were previously passed and bypass the database all together?
I know L2S caches some database calls, but I'm looking for a permanant solution as in, even if the applciation restarts, that cache reloads and never asks the database again.
Are there any f...
LINQ to SQL .Count takes way to much process time and decreases performances.
I am doing a recursive loop and for one child (lets call it parent) I have to check the number of children under it to make a decision if it should be included or not.
The Count is too slow 8 ms :( for 120 parent records.
Any ideas to make it quicker.
...
I'm trying to figure out how to allow a user to enter in a string of tags (keywords separated by spaces) in a textbox to filter a grid of results.
Here are the tables:
PACKETS
*PacketID
Name
PACKETTAGS
*PacketTagID
PacketID
TagID
Tags
*TagID
Name
Here is the basic query without the WHERE parameters:
SELECT
Pac...
I have a code like this.
DBContext is Datacontext instance.
try
{
TBLORGANISM org = new TBLORGANISM();
org.OrganismDesc = p.Subject;
DBContext.TBLORGANISMs.InsertOnSubmit(org);
DBContext.SubmitChanges();
}
catch (Exception)
{...
Hi,
maybe someone can help.
I want to have on mapped Linq-Class different Datatype.
This is working:
private System.Nullable<short> _deleted = 1;
[Column(Storage = "_deleted", Name = "deleted", DbType = "SmallInt", CanBeNull = true)]
public System.Nullable<short> deleted
{
get
{
return this._dele...
I'm inserting approximently 3 million records in a database using this solution. Eventually when the application has been inserting records for a while (my last run lasted around 4 hours), it gives a timeout with the following SqlException:
"SqlExcepetion: Timeout expired. The timeoutperiod elapsed prior to completion of the operatio...
According to Microsoft:
http://msdn.microsoft.com/de-de/library/system.data.linq.mapping.columnattribute.expression.aspx
It's possible to add expression to the Linq-to-SQL Mapping.
But how to configure or add them in Visual Studio in the Designer?
Problem, when I add it manual to thex XYZ.designer.cs it on change it will be lost.
//-...
My controller's call to repository insert method all the values are passed but it doesn't get inserted in my table..
My controller method,
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create([Bind(Exclude = "Id")]FormCollection collection)
{
try
{
MaterialsObj materialsObj = ...
I am having occasional trouble with my C# dbml where it starts not linking properly.
I do not know how to replicate the exact cause of the problem, it was working perfectly until I changed a database table and then deleted the table and readded it with the new schema.
The error message I get is "The type or namespace name 'tbl' could no...