ToList And Querying Multiple Entities?
May 13, 2010
I have the following code for the SelectedIndexChanged event of a drop down list. This works fine as it is but this entity has a relationship to another entity (Genre). if i change the select statement to { m, m.Genre.MovieGenre }).ToList(); it doesnt work as contains anonomyous types.
[code].....
View 1 Replies
Similar Messages:
Nov 5, 2010
I can't find the answer to this easy question, because I don't know the terminology I am looking to use. I have 2 tables, one that is a Users Table, and another (UserProfiles) that extends the Users table to include more info, like Age, Sex, Weight, etc.I am using the Entity Framework as my model, and the UserProfiles inherits from the Users table on a 1:1 basis.
All I need to do is the learn the syntax, that allows LINQ to Entities to query only some of the data from UserProfiles. For example, maybe I only need Sex and Weight, but not Age.
[Code]....
View 4 Replies
Mar 9, 2010
I am trying to use Linq to Entities with the Linq.Dynamic library (via Scott Guthrie) and I'm having some strange issues with querying dates.
[Code]....
This return no results, when it definitely should...
View 1 Replies
Feb 5, 2011
I have a quick question about best practices and especially expected performance for the following scenario:
If I want to query data from multiple servers that contain schematically identital sql databases, would having each server provide a web method that a single client application can consume be an appropriate (and relatively fast) solution?
The data just needs to be consolidated on the client end, where several web methods would have to be consumed serially (or in parallel?) to provide the data to the client. Each server would also be implementing Entity Framework as an ORM.
Performance is my main concern here, would it turn out excessively slow as we start to scale up to more and more servers?
View 2 Replies
Feb 22, 2010
In the code bdehind && syntax does not work, any ideas?
Entities ctx3 = new Entities();
var uniqueQuote = from quot in ctx3.Quotes.Include("aspnet_Users").Include("Enquiries")
where quot.Enquiries.EnquiryId == selectedEnquiryId && [code]...
Error 2 Delegate 'System.Func' does not take '1' arguments C:LocalGarageFinderLocalGarageFinderEnquiryDetail.aspx.cs 56 33 LocalGarageFinder
View 1 Replies
Oct 22, 2010
I've got three different tables of which I need to take data from to use in a gridview.
I have no problem binding data from a single table to a gridview using EF, but how would I go about joining?
I'm thinking about using Linq to Entities to do it, just not sure of the syntax?
View 3 Replies
Sep 24, 2010
What do i need to do in order to be able to query across multiple databases which are in the same db engine?
I have added the .edmx file of 1 database, but i only need 1 view from another db.
View 1 Replies
Dec 14, 2010
I have a model that consists of Order, OrderLine, Product.
I want to create an Order and add OrderLines (each OrderLine related to a Product). I create the Order and add new OrderLines to it. Between posts I store the Order entity in Session (or ViewState). Just so you know I have added suppport for binary serialisation which works fine.
The relationship is therefore Order > OrderLine(s) > Product(s).
You might have already guessed what the problem is - that when I SaveChanges() I get the usual 'AcceptChanges cannot continue because the object's key values conflict with another object in the ObjectStateManager.' error.
I have referred to a number of articles online but none seem to handle this case (where I have the relationship across more than two entities) e.g. [URL].
This must be a very common requirement surely? Is there anyone out there doing the same kind of thing with Entity Framework (and without using DTOs etc)?
View 2 Replies
Jan 16, 2010
My classes look something like this (I include only the relevant properties):
public class Order
{
public virtual Customer Customer { get; set; }
public virtual IEnumerable<OrderLine> OrderLines { get; set; }
}
public class OrderLine
{
public virtual string Product { get; set; } // Simplified
}
Now I What I want is to create a detached criteria that selects all orders for a given customer, and at the same time retrieves only the first 10 OrderLines for each order. The first part is easy:
Customer someCustomerObject = ...; var criteria = DetachedCriteria.For<Order> ).Add(Restrictions.Eq("Customer", someCustomerObject);
But how do I instruct NHibernate to retrieve eagerly the first 10 orderlines for each order retrieved by the criteria above?
I've tried using a Filter based on the following example (taken from Nhibernate documentation):
session.CreateFilter( lazyCollection, "").SetFirstResult(0).SetMaxResults(10).List();
But when I give Order.OrderLines to the CreateFilter method, it retrieves all orderlines first, and then afterwards retrieves the 10 first orderlines, which is not what I want. I also tried combining this with a call to NHibernateUtil.Initialize to no avail.
How do I create a detached criteria for this problem? Or, if that is not entirely possible, how to I retrieve, for each order, the 10 first results only, without fetching the entire collection?
View 1 Replies
Nov 22, 2010
I have a dozen dropdowns and each one is bound to an SP. The page was taking much time to load as time times db is getting connected and sps are called.I thought of using a single sp returning multiple recordsets and iterate through each record set.
Ex:create procedure getdeptsemps
as
begin
select
*
from emp
select
*
from dept
end
I am able to iterate through both the result sets using NextResultset but all I need to know is, how I can assign the recordset into multiple entities like Emp and Dept ?I will assign these Emp and Dept into corresponding dropdown lists.
View 4 Replies
Sep 18, 2010
(Using SQL Server 2008 and ASP.NET MVC2)I have a simple business table and a category table. I have a 3rd table to map business to category, a many-to-many relationship. the Map table contains a BusinessID and CategoryID. I'm lost as to how I can load the categories into my Business View Model using the entities model.Without incorporating categories, my code looks like this:
[Code]....
with Business View Model defined as:
[Code]....
but if i want to populate the Categories with the mapped categories, how would one do that?
View 1 Replies
Nov 16, 2010
I have a datamodel with a couple of tables. One of my tables have about 40 fields (I know that is a lot, but we have to keep the structure in place as we are upgrading a classic ASP project to MVC). Some of my Actions only updates 1 or 2 fields in my table.
Is there a way to create Entities, for instance, that only contains the contact details of the client table, and not any other details, and then another entity that contains only the address details. I don't want to submit the entire row when I only update telephone details, or the client's picture.
View 1 Replies
Jan 27, 2011
We've added a new column to a database table. The column is defined as follows:
Name: DisplayAsSoldOut
Type: Boolean
NOT NULLABLE
Default Value: 0
We've refreshed our EDMX data model and the new column appears just fine. We are on an ASP.NET 4.0 platform using C#.
We have a class defined as PagedList which inherits from List and implenents an interface IPagedList
Within the PagedList we have the following method:
[Code]....
When we reach the following line:
{ AddRange(source.Skip((index) * pageSize).Take(pageSize).ToList()); }
we receive the following Exception ...
Type: System.Data.EntityCommandExecutionException
Inner Exception: "Invalid column name 'DisplayAsSoldOut'."
I've tried searching for this type of exception but to no avail. The column appears in the EDMX dataset just fine. I even created a small throwaway program and imported the EDMX to do a simple read from the database and it worked fine. Has anyone run across something similar?
View 2 Replies
Jul 1, 2010
from user in db.users
View 1 Replies
Feb 17, 2010
I am getting an error on the return saying
Error 18 Cannot convert method group 'ToList' to non-delegate type System.Collections.Generic.List<string>'. Did you intend to invoke the method?
View 2 Replies
Sep 28, 2010
We are starting a new web based product in which we are planning to expose our business logic through WCF services. We will be using ASP.NET 4.0, C#, EF 4.0. In future we want to build iphone applications and WPF applications based on the services. I have been reading a lot about using POCO vs Self Tracking Entities (STE) and from my understand the STEs do not work well with the web scenario.
View 3 Replies
Jan 10, 2010
I have an SQL database which I wish to query, I have the queries set out and working using the SQLDataSource Control.Is there any way of using web methods to query an SQL Database.I realize this may not be ideal when the SQLDataSource control offers such functionality but it is for a piece of college work and I am not entirely sure which way they want it to work, as all it says is to "Implement a client application and a set of web services".
So is it possibile to use a WebMethod to perform SQL based queries or queries which are not SQL based and if so how do you go about creating them?
View 4 Replies
Mar 23, 2010
I have a database which contain job ads/ I have one table "dbo.tbl_jobadvert" which contains the ad itself and another table "dbo.tbl_jobFiles" which contains the path of the documents uploaded in relations to the job advert ( application form, job description, etc )
[Code]....
View 1 Replies
Jul 2, 2010
I'm using Visual Web Developer 2010 Express with SQL server 2008 Express and I'm wondering if it is possible to query the database from within a VB subroutine located within pagename.aspx.vb, rather than just using the asp databound controls on the main page ?
I want to do something like this in the page load routine:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim username As String
username = GetUserName() 'calls function to get current username
Now connect to database and perform SQL command (SELECT FirstName FROM dbo.USERS WHERE UserName = username)
Assign the retuned data to a label: lblFirstName.Text
End Sub
Is it possible ?
View 7 Replies
Jul 1, 2010
I am trying to get my code working as per the instruction on [URL]
Public Delegate Function PredicateWrapperDelegate(Of T, A)(ByVal item As T, ByVal argument As A) As Boolean
Public Class PredicateWrapper(Of T, A)
Private _argument As A
Private _wrapperDelegate As PredicateWrapperDelegate(Of T, A)
Public Sub New(ByVal argument As A, _
ByVal wrapperDelegate As PredicateWrapperDelegate(Of T, A))
_argument = argument
_wrapperDelegate = wrapperDelegate
End Sub
Private Function InnerPredicate(ByVal item As T) As Boolean
Return _wrapperDelegate(item, _argument)
End Function
Public Shared Widening Operator CType( _
ByVal wrapper As PredicateWrapper(Of T, A)) _
As Predicate(Of T)
Return New Predicate(Of T)(AddressOf wrapper.InnerPredicate)
End Operator
End Class
Then I have the function which I have modified to use my department id variable (did)
Function DidMatch(ByVal item As ListDataItem, ByVal did As Integer) As Boolean
Return item.AssigneddepartmentID.Equals(did)
End Function
Then I try to call it from my code:
Dim children As List(Of String) = toplevel.FindAll(New PredicateWrapper(Of Integer, Integer)(Did, AddressOf DidMatch))
I then get an error on DidMatch ... Error Method 'Public Function DidMatch(item As DeptMenuData, did As Integer) As Boolean' does not have a signature compatible with delegate 'Delegate Function PredicateWrapperDelegate(Of Integer, Integer)(item As Integer, argument As Integer) As Boolean'.
View 1 Replies
May 3, 2010
I have developed a data querying application for the Web, this is in a host. What steps should I take if I want this application can also be used with mobile devices.
View 3 Replies
Mar 2, 2010
I have a little problem with a query. I'm selecting data using the between command, But when I select the initial date equal to the final date the query doesn't show data.I know that the problem is the format. In my database I got something like this:2009-05-22 15:32:52.000. But when I send the date parameter from ASP.NET Page I sent only the Date (2009-05-22).So, I want to fix this thing. I cannot change the Datetime inside the database.I was thinking adding 1 day to the final date, So when the user select the same date I change the range behind the scene and then show the data. What do you think?
View 8 Replies
Mar 8, 2011
I have this table in SQL that I'm trying to do some comparison work with Ok, onto the schema. It's like this:
[Code]....
Now, what I want to do is query my database in this manner:Display any records that conflict only Non-priority conflict based on: priority based on the time of day
[Code]....
View 4 Replies
Dec 5, 2010
I am writing an ASP.NET application that suppose to connect to many different data stores and query them for data. Each data store contains different data: it can be an SQL DB, an XML file, or anything that can store data. The result is always an XML.
The remote data stores expose a WCF service (which I will also implement) that will allow me to query the data store and return the results.
My question is: how exactly should I implement the querying mechanism? Should I define my own query language?
View 1 Replies
Mar 16, 2011
I have to check usergroups of LDAP Active Directory for a specific user in C#. Mean I pass this username to a method and it returns me list of group from that user belongs. Im Searching alot But Everytime get new error.
LDAP Path: 192.168.1.4
Domain Name: Arslan
UserName: ArslanP
Password: testad
View 2 Replies