Query body must end with the select clause or group clause error.

Asked By anamika shah
13-Aug-10 12:24 PM
Earn up to 0 extra points for answering this tough question.

public static List<IdNamePair> GetModels(string year, string make, string countryCode, string languageCulture)

      {

           

  if (listModel == null)

        {

          listModel = new List<IdNamePair>();

          using (Entities dataContext = new Entities(System.Configuration.ConfigurationManager.ConnectionStrings["Entities"].ConnectionString))

          {

            listModel.AddRange((from veh in dataContext.vwVehicle

                      join model in dataContext.Models on veh.Model equals model.ModelName && model.LanguageCulture == languageculture

 

                      where (string.IsNullOrEmpty(year) || year.IndexOf(veh.Year) >= 0) && (string.IsNullOrEmpty(make) || make.IndexOf(veh.Make) >= 0)

                      && countryCode == veh.countrycode

                      orderby veh.Model

                      select new IdNamePair() { Id = veh.Model, Name = model.ModelLocalized }).Distinct().ToList());

 

                }

 

        return listModel;

      }

I am using list to return model id and model name.List use linq query.

I am joining table model and vwvehicle on veh.Model equals model.ModelName.It works find until that,but when I add model.LanguageCulture equals languageculture.

Model table has LanguageCulture column and I need to compare that is same that parameter languageculture I am passing in the list. I am getting error

As follow

 

Query body must end with the select clause or group clause error.

 

Can anyone help me with the Linq.

  Even getting error Even I am getting error Operator && can't be applied to operands of type string and string

anamika shah replied to anamika shah
13-Aug-10 12:29 PM

Even I am getting error Operator && can't be applied to operands of type string  and string

  re: Even getting error Even I am getting error Operator && can't be applied to operands of type string and string

lavanya r replied to anamika shah
31-Aug-10 02:11 PM
i made this changes 

var x = from d in obj.PG_PAYMENT_TRANSACTIONS
                        from a in obj.PG_CONTRACT_MASTER
                        where (d.CREATED_DATE.Date) == (DateTime.Now.Date) && d.CONTRACT_ABBR == a.CONTRACT
                        select new { d.TRANSACTION_ID };
                foreach (var item in x)
                {
                    
                }
now i am getting

The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported
Create New Account
Dynamically Composing Expression Predicates Suppose you want to write a LINQ to SQL or Entity Framework query that implements a keyword with PredicateBuilder is with LINQPad . LINQPad lets you instantly test LINQ queries against a database or local collection and has direct Code Here's the complete source: using System; using System.Linq; using System.Linq.Expressions; using System.Collections.Generic; public static class PredicateBuilder { public also shipped as part of LINQKit , a productivity kit for LINQ to SQL and Entity Framework. If you're using LINQ to SQL, you can use the PredicateBuilder source code on Func<Product, bool> > IsSelling() { return p = > !p.Discontinued && p.LastSale > DateTime.Now.AddDays (-30); } } We can extend this by adding a return prod = > !prod.Discontinued && prod. Purchases .Where (purch = > purch.Date > DateTime.Now.AddDays(-30)) .Count() > = minPurchases; } Nesting Predicates Consider the following not null primary key, Name nvarchar(50) not null, ValidFrom datetime, ValidTo datetime ) To retrieve rows valid as of DateTime.Now (the most
Button1_Click( object sender, EventArgs e) { if (TextBox1.Text = = "" ) { Label1.Text = datetime.now.date.tostring(); } else { Label1.Text = "" + TextBox1.Text; } } which way Test.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; / / / <summary> / / / Summary description for Test / / / < / summary> public string GetText( string tbText) { String OutputText = String.Empty; if (String.IsNullOrEmpty(tbText)) { OutputText = DateTime.Now.Date.ToString(); } else { OutputText = "" + tbText; } return OutputText; } } Hi a Test.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; / / / <summary> / / / Summary description for Test / / / < / summary> public string GetText( string tbText) { String OutputText = String.Empty; if (String.IsNullOrEmpty(tbText)) { OutputText = DateTime.Now.Date.ToString(); } else { OutputText = "" + tbText; } return OutputText; } } int getYear( DateTime dt) { return dt.Year; } int getYear() { return DateTime .Now.Year; } protected void Button1_Click( object sender, EventArgs e) { if (TextBox1.Text = = "" ) { int year = getYear(); / / return current year } else { DateTime dt = DateTime .Parse(TextBox1.Text); int year2 = getYear(dt); } } hi
NoRM C# driver with MongoDb, which implements a very nice LINQ interface over database queries. However, the 10Gen people http: / / www 8. Missing from this driver until recently has been the LINQ support I've come to know and love. However, Craig Wilson has created FluentMongo which implements a fully LINQ - compliant set of extension methods around the AsQueryable extension of it possible to execute virtually any MongoDb query via familiar LINQ syntax: _server = MongoServer. Create ( "mongodb: / / localhost" ); _database = _server.GetDatabase( "Cache public class CacheItem : IMongoQuery { public string Id { get; set; } public DateTime Expires { get; set; } public byte[] Item { get; set; } } } The Id a PK via its name); the Expires property is a DateTime expiry date for the cache item, and the Item property implements the IMongoQuery interface which provides us with all the LINQ queryable goodness and access to methods like Save and Remove provides some plumbing: using System; using System.Configuration; using System.Linq; using MongoDB.Driver; using MongoDB.Driver.Builders; using FluentMongo; using FluentMongo.Linq; namespace MongoCache { public static class Helper { private static readonly string if (userName ! = null ) { authentication = string.Concat(userName, ':' , password, '@' ); } if (!string.IsNullOrEmpty(query) && !query.StartsWith( "?" )) { query = string.Concat( '?' , query); } string host = string
sendToPipe) +175 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +137 System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult) +219 System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries) +113 System.Data.Linq.SqlClient.SqlProvider.System.Data Linq.Provider.IProvider.Execute(Expression query) +344 System.Data.Linq.StandardChangeDirector.DynamicInsert(TrackedObject item) +67 System.Data.Linq.StandardChangeDirector.Insert(TrackedObject item) +202 System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode) +260 System.Data Linq.DataContext.SubmitChanges(ConflictMode failureMode) +331 System.Data.Linq.DataContext.SubmitChanges() +19 pages_admin_addNewPopup.save_btn_Click_subSite(Object sender, EventArgs e) in OrganizationID); norg.organizationTypeID = ndb.ExecuteQuery< int > (nqry).FirstOrDefault(); norg.dateCreated = DateTime.Now; / / norg.createdBy_luserID = 1; norg.isActive = true; noh.child_organizationID = organizationID
StockData { / / Date Open High Low Close Volume Adj Close public DateTime Date { get; set; } public double Open { get; set; } public double set; } public double AdjClose { get; set; } public StockData() {} public StockData( DateTime date, double open, double high, double low, double close, long endYear]&g = d&ignore = .csv" ; public DataTable UpdateSymbol( string symbol, DateTime? startDate, DateTime? endDate) { if (!endDate.HasValue) endDate = DateTime.Now; if (!startDate.HasValue) startDate = DateTime.Now.AddYears(-2); if (String.IsNullOrEmpty(symbol)) throw new ArgumentException( "Symbol invalid: " + symbol); / / NOTE: Yahoo's above should be self-explanatory. Note the use of nullable DateTime parameters to allow for a default chart span. Next, I the above method: [OperationContract] public List<StockData> GetStockData( string symbol, DateTime startDate, DateTime endDate) { List<StockData> stockList = new List<StockData> (); Downloader d = new
System.ComponentModel; using System.Data; using System.Diagnostics; using System.Linq; using System.ServiceProcess; using System.Text; using System.Collections; using private void RunService() { string fileName = string.Format("customers_{0}.xml", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")); CustomerCollection customers public static void WriteResponseXML(string xml, string Filename) { if (!String.IsNullOrEmpty(xml)) { String strFilePath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location Enabled = false; MyTimer.Stop(); string startTimeString = ConfigurationSettings.AppSettings["StartTime"].ToString(); DateTime startTime; startTime = DateTime.Now; / / If timestamp = myDateTime.ToString("HH:mm") if(startTimeString = = startTime created at the follwing location: Customers 2nd step. \ r \ n"); DateTime startDate = DateTime.Now; DateTime endDate = DateTime.Now; CustomerCollection customers = null; / / / / CustomerID Inserted / / System.IO.File.AppendAllText
System.ComponentModel; using System.Data; using System.Diagnostics; using System.Linq; using System.ServiceProcess; using System.Text; using System.Collections; using private void RunService() { string fileName = string.Format("customers_{0}.xml", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")); CustomerCollection customers public static void WriteResponseXML(string xml, string Filename) { if (!String.IsNullOrEmpty(xml)) { String strFilePath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location Enabled = false; MyTimer.Stop(); string startTimeString = ConfigurationSettings.AppSettings["StartTime"].ToString(); DateTime startTime; startTime = DateTime.Now; / / If timestamp = myDateTime.ToString("HH:mm") if(startTimeString = = startTime created at the follwing location: Customers 2nd step. \ r \ n"); DateTime startDate = DateTime.Now; DateTime endDate = DateTime.Now; CustomerCollection customers = null; / / / / CustomerID Inserted / / System.IO.File.AppendAllText
System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient; using System.Web.Configuration; using System string Currentname = null; Currentname = Convert.ToString(com.ExecuteScalar()); if (!string.IsNullOrEmpty(Currentname)) { Session["UserAuthentication"] = username; Response.Redirect("ZephyrIndex.aspx"); } else { Session GetType("System.String")); dt.Columns.Add("HireDate", Type.GetType("System.DateTime")); / / fill rows DataRow dr; for(int x = 1;x< = 10 dr["FirstName"] = "Joe" + x; dr["LastName"] = "Smith" + x; dr["HireDate"] = DateTime.Now; dt.Rows.Add(dr); } return dt; } < / script> <!- -#include file