Repository navigation
Open
Description
This is on version 1.0.0. Similar to issue #60.
using System;
using System.Linq;
using ExpressiveSharp;
using ExpressiveSharp.EntityFrameworkCore;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using var connection = new SqliteConnection("Data Source=:memory:");
connection.Open();
using var db = new TestDbContext(connection);
db.Database.EnsureCreated();
Order o = new()
{
Quantity = 101
};
db.Orders.Add(o);
db.SaveChanges();
var bigOrders = db.Orders.Where(o => o.IsBig).Count();
Console.WriteLine(bigOrders);
internal class TestDbContext(SqliteConnection connection) : DbContext
{
public ExpressiveDbSet<Order> Orders => this.ExpressiveSet<Order>();
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite(connection).UseExpressives();
}
[PrimaryKey(nameof(Id))]
public class Order
{
public int Id { get; set; }
public int Quantity { get; set; }
}
public static class OrderExtensions
{
extension(Order o)
{
[Expressive]
public bool IsBig => o.Quantity > 100;
}
}Running this results in:
obj/Debug/net10.0/ExpressiveSharp.Generator/ExpressiveSharp.Generator.PolyfillInterceptorGenerator/PolyfillInterceptors_b5a4d0a8.g.cs(15,145): error CS1026: ) expected
obj/Debug/net10.0/ExpressiveSharp.Generator/ExpressiveSharp.Generator.PolyfillInterceptorGenerator/PolyfillInterceptors_b5a4d0a8.g.cs(15,330): error CS1003: Syntax error, ',' expected
obj/Debug/net10.0/ExpressiveSharp.Generator/ExpressiveSharp.Generator.PolyfillInterceptorGenerator/PolyfillInterceptors_b5a4d0a8.g.cs(15,136): error CS0426: The type name 'extension' does not exist in the type 'OrderExtensions'
obj/Debug/net10.0/ExpressiveSharp.Generator/ExpressiveSharp.Generator.PolyfillInterceptorGenerator/PolyfillInterceptors_b5a4d0a8.g.cs(15,146): error CS0119: 'Order' is a type, which is not valid in the given context
And it can also be reproduced without any EF Core:
using ExpressiveSharp;
var expr = ExpressionPolyfill.Create((Order o) => o.IsBig);
System.Console.WriteLine(expr);
public class Order
{
public int Quantity { get; set; }
}
public static class OrderExtensions
{
extension(Order o)
{
[Expressive]
public bool IsBig => o.Quantity > 100;
}
}Metadata
Metadata
Assignees
Labels
No labels
Activity