LINQ puzzle

P

Paolo

I have the following declarations:

class DBDataContext : DataContext
{
public Table<Activity> Activity;

public DBDataContext(string connectionString) :
base(connectionString) { }
}

Entity class for Table Activity with the following column definition:

[Column(DbType = "Char(1) NOT NULL", CanBeNull=false)]
public char Activity_Type { get; set; }


In Main()
{

DBDataContext db = new DBDataContext(cnStr);

......
GetTypeActivity(db);
}

static void GetTypeActivity(DBDataContext db)
{
Console.WriteLine("Enter type to view (T, R, M, G) :");
char typ = (char)Console.Read();
var acttype = from t in db.Activity
where t.Activity_Type = typ
---------------------
select t;
Console.WriteLine(acttype.ToString()); // overloaded ToString()
}

The underlined expression in GetTypeActivity is giving an error: "Cannot
implicitly
convert type 'char' to 'bool'".

Appreciate an explanation and a solution!

Thanks
 
P

Paolo

Doh!!! thanks, Peter (something about 'wood' and 'trees', methinks)

Peter Duniho said:
[...]
var acttype = from t in db.Activity
where t.Activity_Type = typ
---------------------
select t;
Console.WriteLine(acttype.ToString()); // overloaded
ToString()
}

The underlined expression in GetTypeActivity is giving an error: "Cannot
implicitly
convert type 'char' to 'bool'".

You're missing an '='.
 
P

Paolo

Doh!!! thanks, Peter (something about 'wood' and 'trees', methinks)

Peter Duniho said:
[...]
var acttype = from t in db.Activity
where t.Activity_Type = typ
---------------------
select t;
Console.WriteLine(acttype.ToString()); // overloaded
ToString()
}

The underlined expression in GetTypeActivity is giving an error: "Cannot
implicitly
convert type 'char' to 'bool'".

You're missing an '='.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top