Insert row into table that has FK obtained from another table - linq -c# -


I have 2 tables, customer and client lists. I PK / FK client ID type GUID

Linux, where I want to include in the client intestate table

  ClientInterestRegistration clientRegisteration = new ClientInterestRegistration {ClientID = (from V. DB.Clients where v.Email.Equals (EmailAddress) select New {v.ClientID}). Single (), ClientInterest = SelectedInterests, ..};  

Receives the error: type System.Linq.IQueryable from System.Guid

First, query Consider removing new {...} and changing it:

  client id = (v.Clients in DB where v.Email.Equals (email address) v.ClientID Choose). Single ()  

Are you doing this, as a property to create a new structure with ClientID .

However, you should not work at all directly with the key column. Try setting the client directly to the object:

  client = (Select v.Clients in DB where v.Email.Equals (EmailAddress) v) . Single ()  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -