I try to do things like the following example explains:
the query q works, the query q2 fails with an exception.
I attached a little demo project with an sql Server example Database.
the intention is to pass an entity to an static formatting method to set info (string) for the resulting object:
namespace LLBLGEN_Test2
{
class Program
{
static void Main(string[] args)
{
using (var adapter = new DataAccessAdapter())
{
var metaData = new LinqMetaData(adapter);
var q = (metaData.TableB.Select(x => new TabB
{
ID = x.Id,
Name = x.Name,
TabA = FormatTabAName(x.TableA),
})).ToList();
var q2 = (metaData.TableA.Select(x => new TabA
{
ID = x.Id,
Name = FormatTabAName(x),
})).ToList();
}
}
private static string FormatTabAName(TableAEntity e)
{
if (e != null && !string.IsNullOrEmpty(e.Name))
return string.Format("My name is {0}", e.Name);
return string.Empty;
}
}
internal class TabA
{
public Guid ID { get; set; }
public string Name { get; set; }
}
internal class TabB
{
public Guid ID { get; set; }
public string Name { get; set; }
public string TabA { get; set; }
}
}
Why can use a sub property or related entity but not the entity itself ??
hope you can help me....