 |
BOOK: Beginning ASP.NET 4.5 : in C# and VB
 | This is the forum to discuss the Wrox book Beginning ASP.NET 4.5: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-31180-6 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning ASP.NET 4.5 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|
|

August 30th, 2014, 02:44 PM
|
|
Authorized User
|
|
Join Date: Aug 2014
Posts: 34
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
LINQ question
Hello Imar and TIA:
I am adapting the ASP.Net 4 book to (Ch. 16 with LINQ) to ASP.NET 4.5
In VS4 I have the following:
XYZDataContent db = new XYZDataContent();
var query = from customer in db.Customers where Customer.UserName == User.Identity.Name select Customer.Customer_ID;
I have a customer table with 2 fields 1) Customer_ID (keyfield and Is_identity turned on) and 2) UserName nvarchar field that is their first and last name.
I manually update this customer table and then using a Login control (Ch. 16) assign them a User Name and password for their access.
In the WHERE clause (I get an error in VS4.5) what I want to match is the person that just successfully logged in with their UserName in my existing customer table and then parse the Customer_ID which is unique only to them.
I am now using Entities so I have:
using (XYZEntities myEntities = new XYZEntities())
I need a little help with the new LINQ query
Thanks so much again,
Cliff
|
|

August 30th, 2014, 05:56 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
Can you elaborate on this? I missing the question you're asking.
Cheers,
Imar
|
|

August 30th, 2014, 06:31 PM
|
|
Authorized User
|
|
Join Date: Aug 2014
Posts: 34
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
LINQ question
Hi Imar:
Based upn your ASP.Net 4.0 book I have the following code:
XYZDatabaseContext db = new XYZDatabaseContext();
var query = from Customer in db.Customers where Customer.UserName == User.Identity.Name select Customer.Customer_ID
The idea here is to match a user that has just logged in with a Login control with hs Customer_ID that I have in a Customer table.I'm after the Customer_ID value (an int). This code worked just fine.
I am now going through the 4.5 book where you are talking about Entity Frameworks and I am trying to translate the old 4.0 version (above) into a similar 4.5 version. I have the following:
using (XYZEntities myEntities = new XYZEntities())
{
var query = from customer in myEntities.Customers
where customer.UserName == User.Entity.Name
select customer;
I am getting errors on the WHERE line.
Wondering if you could help.
Thank you,
Clliff
|
|

August 30th, 2014, 07:02 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Clliff,
It would be very helpful if you posted your error message(s) along with the question. Otherwise, I need to create a new site, create a database, create an EF model, create a page, type in your code and run it to see what;s going on which, as I am sure you can imagine, might take a while.
Cheers,
Imar
|
|

August 30th, 2014, 07:59 PM
|
|
Authorized User
|
|
Join Date: Aug 2014
Posts: 34
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
LINQ Conversion
Hi and TIA:
using (XYZEntities myEntities = new XYZEntities())
{
var query = from customer in myEntities.Customers
where customer.UserName == User.Entity.Name
select customer;
I receive the following errors: (All 3 point to the where clause)
Error 3 'System.Security.Principal.IPrincipal' does not contain a definition for 'Entity' and no extension method 'Entity' accepting a first argument of type 'System.Security.Principal.IPrincipal' could be found (are you missing a using directive or an assembly reference?) C:\GolfHandicap(Local Host)\Site\Management\Players.aspx.cs 32 56 Site(3)
Error 1 Cannot convert lambda expression to type 'string' because it is not a delegate type C:\GolfHandicap(Local Host)\Site\Management\Players.aspx.cs 32 24 Site(3)
Error 2 Delegate 'System.Func<GolfDatabaseModel.Customer,int,bool>' does not take 1 arguments C:\GolfHandicap(Local Host)\Site\Management\Players.aspx.cs 32 24 Site(3)
Thanks for looking,
Cliff
|
|

August 31st, 2014, 03:03 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Ah, that helps. It's Identity, not Entity....
Imar
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Linq Question |
barakros |
ASP.NET 3.5 Professionals |
7 |
June 16th, 2010 01:46 AM |
| LINQ Question on Chapter 2 |
robert100 |
BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio |
0 |
June 10th, 2010 05:26 PM |
| Question about LINQ |
maratin |
BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 |
3 |
January 24th, 2010 10:49 AM |
| Linq - A Design Question |
mikener |
LINQ |
3 |
November 14th, 2009 10:47 AM |
| LINQ question |
thangxii |
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 |
6 |
July 6th, 2008 03:13 PM |
|
 |
|